From 712865536bd9150f27ce9f51da9ce4cae1942165 Mon Sep 17 00:00:00 2001 From: HarshaR1642 Date: Mon, 26 Aug 2024 21:42:29 +0530 Subject: [PATCH] update code --- .gitignore | 3 - example/ios/Podfile.lock | 4 +- ios/Geofencing.swift | 20 ++- ios/Geofencing.xcodeproj/project.pbxproj | 1 + lib/commonjs/index.js | 148 ++++++++++++++++++ lib/commonjs/index.js.map | 1 + lib/commonjs/package.json | 1 + lib/module/index.js | 144 +++++++++++++++++ lib/module/index.js.map | 1 + lib/module/package.json | 1 + lib/typescript/commonjs/package.json | 1 + .../commonjs/src/__tests__/index.test.d.ts | 2 + .../src/__tests__/index.test.d.ts.map | 1 + .../typescript/commonjs/src}/index.d.ts | 3 +- lib/typescript/commonjs/src/index.d.ts.map | 1 + lib/typescript/module/package.json | 1 + .../module/src/__tests__/index.test.d.ts | 2 + .../module/src/__tests__/index.test.d.ts.map | 1 + lib/typescript/module/src/index.d.ts | 79 ++++++++++ lib/typescript/module/src/index.d.ts.map | 1 + package.json | 17 +- react-native-geofencing.podspec | 4 +- 22 files changed, 423 insertions(+), 14 deletions(-) create mode 100644 ios/Geofencing.xcodeproj/project.pbxproj create mode 100644 lib/commonjs/index.js create mode 100644 lib/commonjs/index.js.map create mode 100644 lib/commonjs/package.json create mode 100644 lib/module/index.js create mode 100644 lib/module/index.js.map create mode 100644 lib/module/package.json create mode 100644 lib/typescript/commonjs/package.json create mode 100644 lib/typescript/commonjs/src/__tests__/index.test.d.ts create mode 100644 lib/typescript/commonjs/src/__tests__/index.test.d.ts.map rename {src/types => lib/typescript/commonjs/src}/index.d.ts (97%) create mode 100644 lib/typescript/commonjs/src/index.d.ts.map create mode 100644 lib/typescript/module/package.json create mode 100644 lib/typescript/module/src/__tests__/index.test.d.ts create mode 100644 lib/typescript/module/src/__tests__/index.test.d.ts.map create mode 100644 lib/typescript/module/src/index.d.ts create mode 100644 lib/typescript/module/src/index.d.ts.map diff --git a/.gitignore b/.gitignore index 1131c67..67b9c3e 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,3 @@ example/.yarn/* # Turborepo .turbo/ - -# generated by bob -lib/ diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 6354e5a..683504e 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1237,7 +1237,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - react-native-geofencing (0.6.0): + - react-native-geofencing (0.9.0): - DoubleConversion - glog - hermes-engine @@ -1757,7 +1757,7 @@ SPEC CHECKSUMS: React-logger: 0a81d1a40650bbdafb255fe4616edb83feed0ee9 React-Mapbuffer: b758bec0d9994c10a2841dfd5ec70673665fd3e2 React-microtasksnativemodule: f25dba9c8c3f8be0b3368d52b99abd6e381dee1d - react-native-geofencing: 8ae5d2d171423a4f6f6d91735440d6b42465debd + react-native-geofencing: 7b7538824a9e107120f60e85c7ba3933552f920d React-nativeconfig: 7af2ccce165f86b233a9f9d63295f6207e62640e React-NativeModulesApple: db1c1ee9dda26c9e58d824b4100fed83add82ae9 React-perflogger: 7c4e97b47d8bc58c03fad1a6b97d96181b59aa41 diff --git a/ios/Geofencing.swift b/ios/Geofencing.swift index e281b80..f8c2861 100644 --- a/ios/Geofencing.swift +++ b/ios/Geofencing.swift @@ -88,7 +88,7 @@ class Geofencing: RCTEventEmitter, CLLocationManagerDelegate { authorizationSuccessCallback = successCallback if allowAlways && CLLocationManager.authorizationStatus() == .authorizedWhenInUse { - locationManager.requestAlwaysAuthorization() + requestAlwaysAuthorization() } else { locationManager.requestWhenInUseAuthorization() } @@ -203,7 +203,7 @@ class Geofencing: RCTEventEmitter, CLLocationManagerDelegate { authorizationSuccessCallback?([["success": true, "location": getLocationAuthorizationStatus()]]) } else if status == .authorizedWhenInUse { if self.allowAlways { - locationManager.requestAlwaysAuthorization() + requestAlwaysAuthorization() } else { authorizationSuccessCallback?([["success": true, "location": getLocationAuthorizationStatus()]]) } @@ -240,5 +240,21 @@ class Geofencing: RCTEventEmitter, CLLocationManagerDelegate { return message } + private func requestAlwaysAuthorization() { + if isBackgroundLocationUpdatesEnabled() { + locationManager.requestAlwaysAuthorization() + } else { + authorizationSuccessCallback?([["success": false, "location": getLocationAuthorizationStatus(), "reason": "Location updates background mode is not enabled"]]) + authorizationSuccessCallback = nil + } + } + + private func isBackgroundLocationUpdatesEnabled() -> Bool { + if let backgroundModes = Bundle.main.object(forInfoDictionaryKey: "UIBackgroundModes") as? [String] { + return backgroundModes.contains("location") + } + return false + } + } diff --git a/ios/Geofencing.xcodeproj/project.pbxproj b/ios/Geofencing.xcodeproj/project.pbxproj new file mode 100644 index 0000000..fbc6244 --- /dev/null +++ b/ios/Geofencing.xcodeproj/project.pbxproj @@ -0,0 +1 @@ +// Even if this is empty, this is needed for autolinking with your project \ No newline at end of file diff --git a/lib/commonjs/index.js b/lib/commonjs/index.js new file mode 100644 index 0000000..242a3e1 --- /dev/null +++ b/lib/commonjs/index.js @@ -0,0 +1,148 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = exports.Events = exports.Authorization = void 0; +var _reactNative = require("react-native"); +const LINKING_ERROR = `The package '@rn-bridge/react-native-geofencing' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({ + ios: "- You have run 'pod install'\n", + default: '' +}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; +const Geofencing = _reactNative.NativeModules.Geofencing ? _reactNative.NativeModules.Geofencing : new Proxy({}, { + get() { + throw new Error(LINKING_ERROR); + } +}); +const Events = exports.Events = { + Enter: 'onEnter', + Exit: 'onExit' +}; +const Authorization = exports.Authorization = { + Always: 'Always', + WhenInUse: 'WhenInUse', + Restricted: 'Restricted', + Denied: 'Denied', + NotDetermined: 'NotDetermined', + Unknown: 'Unknown' +}; +const nativeModule = _reactNative.Platform.OS === 'ios' ? Geofencing : null; +const geofencingEventEmitter = new _reactNative.NativeEventEmitter(nativeModule); +async function delay(duration) { + return new Promise(resolve => setTimeout(() => resolve(true), duration)); +} +async function onGeofenceTransition(params) { + if (!isOnEnterListenerAdded() || !isOnExitListenerAdded()) { + console.log('Listeners not added, waiting for 5sec...'); + await delay(5000); + } + geofencingEventEmitter.emit(params.event, params.ids); +} +_reactNative.AppRegistry.registerHeadlessTask('onGeofenceTransition', () => onGeofenceTransition); +async function requestAndroidPermissions(params) { + let granted = await _reactNative.PermissionsAndroid.request( + //@ts-ignore + _reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION); + if (granted === _reactNative.PermissionsAndroid.RESULTS.GRANTED && params.allowAlways) { + granted = await _reactNative.PermissionsAndroid.request( + //@ts-ignore + _reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION); + } + const location = await getLocationAuthorizationStatusAndroid(); + return { + success: _reactNative.PermissionsAndroid.RESULTS.GRANTED === granted, + location + }; +} +async function requestLocation(params = {}) { + const requestParams = { + allowWhileUsing: params.allowWhileUsing ?? false, + allowAlways: params.allowAlways ?? false + }; + if (_reactNative.Platform.OS === 'android') { + return requestAndroidPermissions(requestParams); + } + return new Promise(resolve => { + Geofencing.requestLocation(requestParams, response => { + resolve(response); + }); + }); +} +async function getLocationAuthorizationStatusAndroid() { + let location = 'Denied'; + const whenInUse = await _reactNative.PermissionsAndroid.check( + //@ts-ignore + _reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION); + const background = await _reactNative.PermissionsAndroid.check( + //@ts-ignore + _reactNative.PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION); + if (whenInUse) { + location = 'WhenInUse'; + } + if (background) { + location = 'Always'; + } + return location; +} +async function getLocationAuthorizationStatus() { + if (_reactNative.Platform.OS === 'android') { + return await getLocationAuthorizationStatusAndroid(); + } + return await Geofencing.getLocationAuthorizationStatus(); +} +async function getCurrentLocation() { + return await Geofencing.getCurrentLocation(); +} +async function addGeofence(params = {}) { + if (!params.id || !params.latitude || !params.longitude || !params.radius) { + return Promise.reject('invalid parameters'); + } + return await Geofencing.addGeofence(params); +} +async function removeGeofence(id) { + if (!id) { + return Promise.reject('id cannot be null or undefined'); + } + return await Geofencing.removeGeofence(id); +} +async function getRegisteredGeofences() { + return await Geofencing.getRegisteredGeofences(); +} +async function removeAllGeofence() { + return await Geofencing.removeAllGeofence(); +} +function onEnter(callback) { + return geofencingEventEmitter.addListener(Events.Enter, callback); +} +function onExit(callback) { + return geofencingEventEmitter.addListener(Events.Exit, callback); +} +function removeOnEnterListener() { + geofencingEventEmitter.removeAllListeners(Events.Enter); +} +function removeOnExitListener() { + geofencingEventEmitter.removeAllListeners(Events.Exit); +} +function isOnEnterListenerAdded() { + return geofencingEventEmitter.listenerCount(Events.Enter) > 0; +} +function isOnExitListenerAdded() { + return geofencingEventEmitter.listenerCount(Events.Exit) > 0; +} +var _default = exports.default = { + requestLocation, + getLocationAuthorizationStatus, + getCurrentLocation, + addGeofence, + removeGeofence, + getRegisteredGeofences, + removeAllGeofence, + onEnter, + onExit, + removeOnEnterListener, + removeOnExitListener, + isOnEnterListenerAdded, + isOnExitListenerAdded, + geofencingEventEmitter +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/commonjs/index.js.map b/lib/commonjs/index.js.map new file mode 100644 index 0000000..192ea80 --- /dev/null +++ b/lib/commonjs/index.js.map @@ -0,0 +1 @@ +{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","Geofencing","NativeModules","Proxy","get","Error","Events","exports","Enter","Exit","Authorization","Always","WhenInUse","Restricted","Denied","NotDetermined","Unknown","nativeModule","OS","geofencingEventEmitter","NativeEventEmitter","delay","duration","Promise","resolve","setTimeout","onGeofenceTransition","params","isOnEnterListenerAdded","isOnExitListenerAdded","console","log","emit","event","ids","AppRegistry","registerHeadlessTask","requestAndroidPermissions","granted","PermissionsAndroid","request","PERMISSIONS","ACCESS_FINE_LOCATION","RESULTS","GRANTED","allowAlways","ACCESS_BACKGROUND_LOCATION","location","getLocationAuthorizationStatusAndroid","success","requestLocation","requestParams","allowWhileUsing","response","whenInUse","check","background","getLocationAuthorizationStatus","getCurrentLocation","addGeofence","id","latitude","longitude","radius","reject","removeGeofence","getRegisteredGeofences","removeAllGeofence","onEnter","callback","addListener","onExit","removeOnEnterListener","removeAllListeners","removeOnExitListener","listenerCount","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,MAAMC,aAAa,GAClB,6FAA6F,GAC7FC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEhC,MAAMC,UAAU,GAAGC,0BAAa,CAACD,UAAU,GACxCC,0BAAa,CAACD,UAAU,GACxB,IAAIE,KAAK,CACV,CAAC,CAAC,EACF;EACCC,GAAGA,CAAA,EAAG;IACL,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAC/B;AACD,CACD,CAAC;AAEK,MAAMU,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG;EACrBE,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACP,CAAC;AAEM,MAAMC,aAAa,GAAAH,OAAA,CAAAG,aAAA,GAAG;EAC5BC,MAAM,EAAE,QAAQ;EAChBC,SAAS,EAAE,WAAW;EACtBC,UAAU,EAAE,YAAY;EACxBC,MAAM,EAAE,QAAQ;EAChBC,aAAa,EAAE,eAAe;EAC9BC,OAAO,EAAE;AACV,CAAC;AAED,MAAMC,YAAY,GAAGpB,qBAAQ,CAACqB,EAAE,KAAK,KAAK,GAAGjB,UAAU,GAAG,IAAI;AAC9D,MAAMkB,sBAAsB,GAAG,IAAIC,+BAAkB,CAACH,YAAY,CAAC;AAEnE,eAAeI,KAAKA,CAACC,QAAgB,EAAoB;EACxD,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAKC,UAAU,CAAC,MAAMD,OAAO,CA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;EACjBC,OAAO;EACPG,MAAM;EACNC,qBAAqB;EACrBE,oBAAoB;EACpB9C,sBAAsB;EACtBC,qBAAqB;EACrBV;AACD,CAAC","ignoreList":[]} diff --git a/lib/commonjs/package.json b/lib/commonjs/package.json new file mode 100644 index 0000000..729ac4d --- /dev/null +++ b/lib/commonjs/package.json @@ -0,0 +1 @@ +{"type":"commonjs"} diff --git a/lib/module/index.js b/lib/module/index.js new file mode 100644 index 0000000..0f306b2 --- /dev/null +++ b/lib/module/index.js @@ -0,0 +1,144 @@ +"use strict"; + +import { NativeModules, Platform, AppRegistry, NativeEventEmitter, PermissionsAndroid } from 'react-native'; +const LINKING_ERROR = `The package '@rn-bridge/react-native-geofencing' doesn't seem to be linked. Make sure: \n\n` + Platform.select({ + ios: "- You have run 'pod install'\n", + default: '' +}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; +const Geofencing = NativeModules.Geofencing ? NativeModules.Geofencing : new Proxy({}, { + get() { + throw new Error(LINKING_ERROR); + } +}); +export const Events = { + Enter: 'onEnter', + Exit: 'onExit' +}; +export const Authorization = { + Always: 'Always', + WhenInUse: 'WhenInUse', + Restricted: 'Restricted', + Denied: 'Denied', + NotDetermined: 'NotDetermined', + Unknown: 'Unknown' +}; +const nativeModule = Platform.OS === 'ios' ? Geofencing : null; +const geofencingEventEmitter = new NativeEventEmitter(nativeModule); +async function delay(duration) { + return new Promise(resolve => setTimeout(() => resolve(true), duration)); +} +async function onGeofenceTransition(params) { + if (!isOnEnterListenerAdded() || !isOnExitListenerAdded()) { + console.log('Listeners not added, waiting for 5sec...'); + await delay(5000); + } + geofencingEventEmitter.emit(params.event, params.ids); +} +AppRegistry.registerHeadlessTask('onGeofenceTransition', () => onGeofenceTransition); +async function requestAndroidPermissions(params) { + let granted = await PermissionsAndroid.request( + //@ts-ignore + PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION); + if (granted === PermissionsAndroid.RESULTS.GRANTED && params.allowAlways) { + granted = await PermissionsAndroid.request( + //@ts-ignore + PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION); + } + const location = await getLocationAuthorizationStatusAndroid(); + return { + success: PermissionsAndroid.RESULTS.GRANTED === granted, + location + }; +} +async function requestLocation(params = {}) { + const requestParams = { + allowWhileUsing: params.allowWhileUsing ?? false, + allowAlways: params.allowAlways ?? false + }; + if (Platform.OS === 'android') { + return requestAndroidPermissions(requestParams); + } + return new Promise(resolve => { + Geofencing.requestLocation(requestParams, response => { + resolve(response); + }); + }); +} +async function getLocationAuthorizationStatusAndroid() { + let location = 'Denied'; + const whenInUse = await PermissionsAndroid.check( + //@ts-ignore + PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION); + const background = await PermissionsAndroid.check( + //@ts-ignore + PermissionsAndroid.PERMISSIONS.ACCESS_BACKGROUND_LOCATION); + if (whenInUse) { + location = 'WhenInUse'; + } + if (background) { + location = 'Always'; + } + return location; +} +async function getLocationAuthorizationStatus() { + if (Platform.OS === 'android') { + return await getLocationAuthorizationStatusAndroid(); + } + return await Geofencing.getLocationAuthorizationStatus(); +} +async function getCurrentLocation() { + return await Geofencing.getCurrentLocation(); +} +async function addGeofence(params = {}) { + if (!params.id || !params.latitude || !params.longitude || !params.radius) { + return Promise.reject('invalid parameters'); + } + return await Geofencing.addGeofence(params); +} +async function removeGeofence(id) { + if (!id) { + return Promise.reject('id cannot be null or undefined'); + } + return await Geofencing.removeGeofence(id); +} +async function getRegisteredGeofences() { + return await Geofencing.getRegisteredGeofences(); +} +async function removeAllGeofence() { + return await Geofencing.removeAllGeofence(); +} +function onEnter(callback) { + return geofencingEventEmitter.addListener(Events.Enter, callback); +} +function onExit(callback) { + return geofencingEventEmitter.addListener(Events.Exit, callback); +} +function removeOnEnterListener() { + geofencingEventEmitter.removeAllListeners(Events.Enter); +} +function removeOnExitListener() { + geofencingEventEmitter.removeAllListeners(Events.Exit); +} +function isOnEnterListenerAdded() { + return geofencingEventEmitter.listenerCount(Events.Enter) > 0; +} +function isOnExitListenerAdded() { + return geofencingEventEmitter.listenerCount(Events.Exit) > 0; +} +export default { + requestLocation, + getLocationAuthorizationStatus, + getCurrentLocation, + addGeofence, + removeGeofence, + getRegisteredGeofences, + removeAllGeofence, + onEnter, + onExit, + removeOnEnterListener, + removeOnExitListener, + isOnEnterListenerAdded, + isOnExitListenerAdded, + geofencingEventEmitter +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/module/index.js.map b/lib/module/index.js.map new file mode 100644 index 0000000..9dd8cda --- /dev/null +++ b/lib/module/index.js.map @@ -0,0 +1 @@ +{"version":3,"names":["NativeModules","Platform","AppRegistry","NativeEventEmitter","PermissionsAndroid","LINKING_ERROR","select","ios","default","Geofencing","Proxy","get","Error","Events","Enter","Exit","Authorization","Always","WhenInUse","Restricted","Denied","NotDetermined","Unknown","nativeModule","OS","geofencingEventEmitter","delay","duration","Promise","resolve","setTimeout","onGeofenceTransition","params","isOnEnterListenerAdded","isOnExitListenerAdded","console","log","emit","event","ids","registerHeadlessTask","requestAndroidPermissions","granted","request","PERMISSIONS","ACCESS_FINE_LOCATION","RESULTS","GRANTED","allowAlways","ACCESS_BACKGROUND_LOCATION","location","getLocationAuthorizationStatusAndroid","success","requestLocation","requestParams","allowWhileUsing","response","whenInUse","check","background","getLocationAuthorizationStatus","getCurrentLocation","addGeofence","id","latitude","longitude","radius","reject","removeGeofence","getRegisteredGeofences","removeAllGeofence","onEnter","callback","addListener","onExit","removeOnEnterListener","removeAllListeners","removeOnExitListener","listenerCount"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SACCA,aAAa,EACbC,QAAQ,EACRC,WAAW,EACXC,kBAAkB,EAElBC,kBAAkB,QACZ,cAAc;AAErB,MAAMC,aAAa,GAClB,6FAA6F,GAC7FJ,QAAQ,CAACK,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA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,MAAM,CAACC,KAAK,EAAE0D,QAAQ,CAAC;AAClE;AAEA,SAASE,MAAMA,CAACF,QAAiC,EAAqB;EACrE,OAAO/C,sBAAsB,CAACgD,WAAW,CAAC5D,MAAM,CAACE,IAAI,EAAEyD,QAAQ,CAAC;AACjE;AAEA,SAASG,qBAAqBA,CAAA,EAAS;EACtClD,sBAAsB,CAACmD,kBAAkB,CAAC/D,MAAM,CAACC,KAAK,CAAC;AACxD;AAEA,SAAS+D,oBAAoBA,CAAA,EAAS;EACrCpD,sBAAsB,CAACmD,kBAAkB,CAAC/D,MAAM,CAACE,IAAI,CAAC;AACvD;AAEA,SAASkB,sBAAsBA,CAAA,EAAY;EAC1C,OAAOR,sBAAsB,CAACqD,aAAa,CAACjE,MAAM,CAACC,KAAK,CAAC,GAAG,CAAC;AAC9D;AAEA,SAASoB,qBAAqBA,CAAA,EAAY;EACzC,OAAOT,sBAAsB,CAACqD,aAAa,CAACjE,MAAM,CAACE,IAAI,CAAC,GAAG,CAAC;AAC7D;AAGA,eAAe;EACdsC,eAAe;EACfO,8BAA8B;EAC9BC,kBAAkB;EAClBC,WAAW;EACXM,cAAc;EACdC,sBAAsB;EACtBC,iBAAiB;EACjBC,OAAO;EACPG,MAAM;EACNC,qBAAqB;EACrBE,oBAAoB;EACpB5C,sBAAsB;EACtBC,qBAAqB;EACrBT;AACD,CAAC","ignoreList":[]} diff --git a/lib/module/package.json b/lib/module/package.json new file mode 100644 index 0000000..089153b --- /dev/null +++ b/lib/module/package.json @@ -0,0 +1 @@ +{"type":"module"} diff --git a/lib/typescript/commonjs/package.json b/lib/typescript/commonjs/package.json new file mode 100644 index 0000000..729ac4d --- /dev/null +++ b/lib/typescript/commonjs/package.json @@ -0,0 +1 @@ +{"type":"commonjs"} diff --git a/lib/typescript/commonjs/src/__tests__/index.test.d.ts b/lib/typescript/commonjs/src/__tests__/index.test.d.ts new file mode 100644 index 0000000..121d59b --- /dev/null +++ b/lib/typescript/commonjs/src/__tests__/index.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=index.test.d.ts.map \ No newline at end of file diff --git a/lib/typescript/commonjs/src/__tests__/index.test.d.ts.map b/lib/typescript/commonjs/src/__tests__/index.test.d.ts.map new file mode 100644 index 0000000..648a3f9 --- /dev/null +++ b/lib/typescript/commonjs/src/__tests__/index.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../../src/__tests__/index.test.tsx"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/types/index.d.ts b/lib/typescript/commonjs/src/index.d.ts similarity index 97% rename from src/types/index.d.ts rename to lib/typescript/commonjs/src/index.d.ts index 54f8444..15b726b 100644 --- a/src/types/index.d.ts +++ b/lib/typescript/commonjs/src/index.d.ts @@ -75,4 +75,5 @@ declare const _default: { isOnExitListenerAdded: typeof isOnExitListenerAdded; geofencingEventEmitter: NativeEventEmitter; }; -export default _default; \ No newline at end of file +export default _default; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/typescript/commonjs/src/index.d.ts.map b/lib/typescript/commonjs/src/index.d.ts.map new file mode 100644 index 0000000..316d76f --- /dev/null +++ b/lib/typescript/commonjs/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIN,kBAAkB,EAClB,KAAK,iBAAiB,EAEtB,MAAM,cAAc,CAAC;AAmBtB,eAAO,MAAM,MAAM;;;CAGlB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;CAOzB,CAAC;AAuBF,KAAK,yBAAyB,GAAG;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,2BAA2B,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAyBF,iBAAe,eA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CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,iBAAiB,CAErE;AAED,iBAAS,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,iBAAiB,CAEpE;AAED,iBAAS,qBAAqB,IAAI,IAAI,CAErC;AAED,iBAAS,oBAAoB,IAAI,IAAI,CAEpC;AAED,iBAAS,sBAAsB,IAAI,OAAO,CAEzC;AAED,iBAAS,qBAAqB,IAAI,OAAO,CAExC;;;;;;;;;;;;;;;;;AAGD,wBAeC"} \ No newline at end of file diff --git a/lib/typescript/module/package.json b/lib/typescript/module/package.json new file mode 100644 index 0000000..089153b --- /dev/null +++ b/lib/typescript/module/package.json @@ -0,0 +1 @@ +{"type":"module"} diff --git a/lib/typescript/module/src/__tests__/index.test.d.ts b/lib/typescript/module/src/__tests__/index.test.d.ts new file mode 100644 index 0000000..121d59b --- /dev/null +++ b/lib/typescript/module/src/__tests__/index.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=index.test.d.ts.map \ No newline at end of file diff --git a/lib/typescript/module/src/__tests__/index.test.d.ts.map b/lib/typescript/module/src/__tests__/index.test.d.ts.map new file mode 100644 index 0000000..648a3f9 --- /dev/null +++ b/lib/typescript/module/src/__tests__/index.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../../src/__tests__/index.test.tsx"],"names":[],"mappings":""} \ No newline at end of file diff --git a/lib/typescript/module/src/index.d.ts b/lib/typescript/module/src/index.d.ts new file mode 100644 index 0000000..15b726b --- /dev/null +++ b/lib/typescript/module/src/index.d.ts @@ -0,0 +1,79 @@ +import { NativeEventEmitter, type EventSubscription } from 'react-native'; +export declare const Events: { + Enter: string; + Exit: string; +}; +export declare const Authorization: { + Always: string; + WhenInUse: string; + Restricted: string; + Denied: string; + NotDetermined: string; + Unknown: string; +}; +type requestLocationParamsType = { + allowWhileUsing?: boolean; + allowAlways?: boolean; +}; +type requestLocationResponseType = { + success: boolean; + location: string; +}; +declare function requestLocation(params?: requestLocationParamsType): Promise; +declare function getLocationAuthorizationStatus(): Promise; +export type locationType = { + latitude: number; + longitude: number; + altitude: number; + name: string; + city: string; + state: string; + country: string; + postalCode: string; + isoCountryCode: string; + timeZone: string; +}; +declare function getCurrentLocation(): Promise; +type paramsType = { + id: string; + latitude: number; + longitude: number; + radius: number; +}; +type returnType = { + success: boolean; + id: string; + error: string; +}; +declare function addGeofence(params?: paramsType): Promise; +declare function removeGeofence(id: string): Promise; +declare function getRegisteredGeofences(): Promise; +type removeAllGeofenceReturnType = { + success: boolean; + type: string; +}; +declare function removeAllGeofence(): Promise; +declare function onEnter(callback: (ids: string[]) => void): EventSubscription; +declare function onExit(callback: (ids: string[]) => void): EventSubscription; +declare function removeOnEnterListener(): void; +declare function removeOnExitListener(): void; +declare function isOnEnterListenerAdded(): boolean; +declare function isOnExitListenerAdded(): boolean; +declare const _default: { + requestLocation: typeof requestLocation; + getLocationAuthorizationStatus: typeof getLocationAuthorizationStatus; + getCurrentLocation: typeof getCurrentLocation; + addGeofence: typeof addGeofence; + removeGeofence: typeof removeGeofence; + getRegisteredGeofences: typeof getRegisteredGeofences; + removeAllGeofence: typeof removeAllGeofence; + onEnter: typeof onEnter; + onExit: typeof onExit; + removeOnEnterListener: typeof removeOnEnterListener; + removeOnExitListener: typeof removeOnExitListener; + isOnEnterListenerAdded: typeof isOnEnterListenerAdded; + isOnExitListenerAdded: typeof isOnExitListenerAdded; + geofencingEventEmitter: NativeEventEmitter; +}; +export default _default; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/typescript/module/src/index.d.ts.map b/lib/typescript/module/src/index.d.ts.map new file mode 100644 index 0000000..316d76f --- /dev/null +++ b/lib/typescript/module/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIN,k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OAAO,CAAC,UAAU,CAAC,CAKrB;AAED,iBAAe,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAK7D;AAED,iBAAe,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAEzD;AAED,KAAK,2BAA2B,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,iBAAe,iBAAiB,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAEvE;AAED,iBAAS,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,iBAAiB,CAErE;AAED,iBAAS,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,iBAAiB,CAEpE;AAED,iBAAS,qBAAqB,IAAI,IAAI,CAErC;AAED,iBAAS,oBAAoB,IAAI,IAAI,CAEpC;AAED,iBAAS,sBAAsB,IAAI,OAAO,CAEzC;AAED,iBAAS,qBAAqB,IAAI,OAAO,CAExC;;;;;;;;;;;;;;;;;AAGD,wBAeC"} \ No newline at end of file diff --git a/package.json b/package.json index 2383828..d20bde6 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "@rn-bridge/react-native-geofencing", - "version": "0.8.0", + "version": "0.9.0", "description": "Native modules to determine if a location is within defined geographical boundaries", "source": "./src/index.tsx", - "main": "./src/index.tsx", + "main": "./lib/commonjs/index.js", "module": "./lib/module/index.js", - "types": "./src/types/index.d.ts", + "types": "./lib/typescript/commonjs/src/index.d.ts", "files": [ "src", + "lib", "android", "ios", "cpp", @@ -75,7 +76,11 @@ "react-native": "*" }, "jest": { - "preset": "react-native" + "preset": "react-native", + "modulePathIgnorePatterns": [ + "/example/node_modules", + "/lib/" + ] }, "packageManager": "yarn@3.6.1", "eslintConfig": { @@ -99,6 +104,10 @@ ] } }, + "eslintIgnore": [ + "node_modules/", + "lib/" + ], "react-native-builder-bob": { "source": "src", "output": "lib", diff --git a/react-native-geofencing.podspec b/react-native-geofencing.podspec index 4c39470..dc47c61 100644 --- a/react-native-geofencing.podspec +++ b/react-native-geofencing.podspec @@ -11,8 +11,8 @@ Pod::Spec.new do |s| s.license = package["license"] s.authors = package["author"] - s.platforms = { :ios => min_ios_version_supported } - s.source = { :git => "https://github.com/sriharshamadamanchi/rn-bridge/react-native-geofencing.git", :tag => "#{s.version}" } + s.platforms = { :ios => "12.0" } + s.source = { :git => "https://github.com/rn-bridge/react-native-geofencing.git", :tag => "#{s.version}" } s.source_files = "ios/**/*.{h,m,mm,swift}"