react-native-background-geolocation 4.19.2 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -0
- package/README.md +4 -4
- package/RNBackgroundGeolocation.podspec +25 -8
- package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/build.gradle +22 -56
- package/android/proguard-rules.pro +66 -38
- package/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/HeadlessTask.java +44 -44
- package/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/RNBackgroundGeolocation.java +8 -8
- package/android/src/main/java/com/transistorsoft/rnbackgroundgeolocation/RNBackgroundGeolocationModule.java +318 -281
- package/babel.config.js +5 -0
- package/expo/plugin/build/androidPlugin.js.map +1 -1
- package/expo/plugin/tsconfig.tsbuildinfo +1 -0
- package/ios/RNBackgroundGeolocation/RNBackgroundGeolocation.h +6 -0
- package/ios/RNBackgroundGeolocation/{RNBackgroundGeolocation.m → RNBackgroundGeolocation.mm} +216 -164
- package/jest.config.js +14 -0
- package/mocks/react-native.js +52 -0
- package/package.json +28 -13
- package/src/DeviceSettings.js +7 -24
- package/src/Logger.js +18 -46
- package/src/NativeModule.js +110 -268
- package/src/{TransistorAuthorizationToken.js → TransistorAuthorizationService.js} +17 -19
- package/src/index.d.ts +13 -1
- package/src/index.js +271 -467
- package/src/native/specs/NativeBackgroundGeolocation.ts +49 -0
- package/src/specs/NativeRNBackgroundGeolocation.js +104 -0
- package/tests/enums-bridge-test.js +16 -0
- package/tests/enums.test.js +23 -0
- package/tests/ready-compound.test.js +28 -0
- package/tests/ready.test.js +6 -0
- package/tests-types/config-surface.ts +38 -0
- package/tests-types/enums-smoke-test.ts +35 -0
- package/tests-types/events-typing.ts +23 -0
- package/tests-types/flat-config.ts +0 -0
- package/tests-types/ok.ts +20 -0
- package/tests-types/tsconfig.json +14 -0
- package/typedoc.json +49 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom +0 -9
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/3.7.0/tslocationmanager-3.7.0.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager/maven-metadata.xml +0 -13
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar +0 -0
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.aar.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom +0 -9
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.md5 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha1 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha256 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/3.7.0/tslocationmanager-v21-3.7.0.pom.sha512 +0 -1
- package/android/libs/com/transistorsoft/tslocationmanager-v21/maven-metadata.xml +0 -13
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/Info.plist +0 -61
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/_CodeSignature/CodeDirectory +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/_CodeSignature/CodeRequirements +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/_CodeSignature/CodeResources +0 -2033
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/_CodeSignature/CodeSignature +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/AtomicBoolean.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/ConfigModule.h +0 -21
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/HttpRequest.h +0 -21
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/HttpResponse.h +0 -29
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/LocationManager.h +0 -55
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/LogQuery.h +0 -13
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/SOMotionDetector.h +0 -141
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/SQLQuery.h +0 -34
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSActivityChangeEvent.h +0 -16
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSAuthorization.h +0 -38
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSAuthorizationEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSCallback.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSConfig.h +0 -310
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSConnectivityChangeEvent.h +0 -17
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSCurrentPositionRequest.h +0 -43
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSDeviceInfo.h +0 -24
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSEnabledChangeEvent.h +0 -15
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSGeofence.h +0 -54
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSGeofenceEvent.h +0 -64
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSGeofenceManager.h +0 -54
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSGeofencesChangeEvent.h +0 -17
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSHeartbeatEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSHttpEvent.h +0 -19
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSHttpService.h +0 -58
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSLocation.h +0 -105
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSLocationManager.h +0 -315
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSPowerSaveChangeEvent.h +0 -14
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSProviderChangeEvent.h +0 -20
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSReachability.h +0 -106
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSSchedule.h +0 -40
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSScheduleEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TSWatchPositionRequest.h +0 -41
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Headers/TransistorAuthorizationToken.h +0 -31
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Info.plist +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Miniball/Miniball.hpp +0 -525
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/Modules/module.modulemap +0 -6
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/PrivacyInfo.xcprivacy +0 -36
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/_CodeSignature/CodeRequirements +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/_CodeSignature/CodeResources +0 -642
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64/TSLocationManager.framework/_CodeSignature/CodeSignature +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/AtomicBoolean.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/ConfigModule.h +0 -21
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/HttpRequest.h +0 -21
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/HttpResponse.h +0 -29
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/LocationManager.h +0 -55
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/LogQuery.h +0 -13
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/SOMotionDetector.h +0 -141
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/SQLQuery.h +0 -34
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSActivityChangeEvent.h +0 -16
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSAuthorization.h +0 -38
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSAuthorizationEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSCallback.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSConfig.h +0 -310
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSConnectivityChangeEvent.h +0 -17
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSCurrentPositionRequest.h +0 -43
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSDeviceInfo.h +0 -24
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSEnabledChangeEvent.h +0 -15
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSGeofence.h +0 -54
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSGeofenceEvent.h +0 -64
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSGeofenceManager.h +0 -54
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSGeofencesChangeEvent.h +0 -17
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSHeartbeatEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSHttpEvent.h +0 -19
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSHttpService.h +0 -58
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSLocation.h +0 -105
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSLocationManager.h +0 -315
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSPowerSaveChangeEvent.h +0 -14
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSProviderChangeEvent.h +0 -20
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSReachability.h +0 -106
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSSchedule.h +0 -40
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSScheduleEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TSWatchPositionRequest.h +0 -41
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Headers/TransistorAuthorizationToken.h +0 -31
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Modules/module.modulemap +0 -6
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Resources/Info.plist +0 -50
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Resources/Miniball/Miniball.hpp +0 -525
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/Resources/PrivacyInfo.xcprivacy +0 -36
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/_CodeSignature/CodeRequirements +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/_CodeSignature/CodeResources +0 -536
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-maccatalyst/TSLocationManager.framework/_CodeSignature/CodeSignature +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/AtomicBoolean.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/ConfigModule.h +0 -21
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/HttpRequest.h +0 -21
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/HttpResponse.h +0 -29
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/LocationManager.h +0 -55
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/LogQuery.h +0 -13
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/SOMotionDetector.h +0 -141
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/SQLQuery.h +0 -34
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSActivityChangeEvent.h +0 -16
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSAuthorization.h +0 -38
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSAuthorizationEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSCallback.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSConfig.h +0 -310
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSConnectivityChangeEvent.h +0 -17
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSCurrentPositionRequest.h +0 -43
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSDeviceInfo.h +0 -24
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSEnabledChangeEvent.h +0 -15
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSGeofence.h +0 -54
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSGeofenceEvent.h +0 -64
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSGeofenceManager.h +0 -54
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSGeofencesChangeEvent.h +0 -17
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSHeartbeatEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSHttpEvent.h +0 -19
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSHttpService.h +0 -58
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSLocation.h +0 -105
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSLocationManager.h +0 -315
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSPowerSaveChangeEvent.h +0 -14
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSProviderChangeEvent.h +0 -20
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSReachability.h +0 -106
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSSchedule.h +0 -40
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSScheduleEvent.h +0 -18
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TSWatchPositionRequest.h +0 -41
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Headers/TransistorAuthorizationToken.h +0 -31
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Info.plist +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Miniball/Miniball.hpp +0 -525
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/Modules/module.modulemap +0 -6
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/PrivacyInfo.xcprivacy +0 -36
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/TSLocationManager +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeRequirements +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeResources +0 -642
- package/src/Events.js +0 -17
- package/src/declarations/BackgroundGeolocation.d.ts +0 -1683
- /package/{ios/RNBackgroundGeolocation/TSLocationManager.xcframework/ios-arm64_x86_64-simulator/TSLocationManager.framework/_CodeSignature/CodeSignature → tests-types/api-surface.ts} +0 -0
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
package com.transistorsoft.rnbackgroundgeolocation;
|
|
2
2
|
|
|
3
|
+
import com.transistorsoft.rnbackgroundgeolocation.NativeRNBackgroundGeolocationSpec;
|
|
4
|
+
|
|
3
5
|
import android.Manifest;
|
|
4
6
|
import android.app.Activity;
|
|
5
7
|
import android.content.Context;
|
|
6
8
|
import android.content.Intent;
|
|
7
|
-
import android.util.Log;
|
|
8
9
|
import android.os.Build;
|
|
10
|
+
import android.util.Log;
|
|
9
11
|
|
|
10
12
|
import com.facebook.react.bridge.ActivityEventListener;
|
|
11
|
-
import com.facebook.react.bridge.Callback;
|
|
12
13
|
import com.facebook.react.bridge.LifecycleEventListener;
|
|
14
|
+
import com.facebook.react.bridge.Promise;
|
|
13
15
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
14
16
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
15
17
|
import com.facebook.react.bridge.ReactMethod;
|
|
@@ -21,23 +23,27 @@ import com.facebook.react.bridge.WritableArray;
|
|
|
21
23
|
import com.facebook.react.bridge.WritableMap;
|
|
22
24
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
23
25
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
24
|
-
import com.facebook.react.
|
|
26
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
27
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
25
28
|
|
|
26
29
|
import org.greenrobot.eventbus.EventBus;
|
|
27
30
|
import org.json.JSONArray;
|
|
28
31
|
import org.json.JSONException;
|
|
29
32
|
import org.json.JSONObject;
|
|
30
33
|
|
|
34
|
+
import com.transistorsoft.locationmanager.config.TSConfig;
|
|
35
|
+
import com.transistorsoft.locationmanager.config.edit.Editor;
|
|
36
|
+
import com.transistorsoft.locationmanager.event.EventName;
|
|
31
37
|
import com.transistorsoft.locationmanager.event.FinishHeadlessTaskEvent;
|
|
32
38
|
import com.transistorsoft.locationmanager.event.HeadlessEvent;
|
|
33
39
|
import com.google.android.gms.common.GoogleApiAvailability;
|
|
34
40
|
|
|
35
41
|
import com.transistorsoft.locationmanager.adapter.BackgroundGeolocation;
|
|
36
|
-
|
|
42
|
+
|
|
37
43
|
import com.transistorsoft.locationmanager.adapter.callback.*;
|
|
38
|
-
|
|
39
|
-
import com.transistorsoft.locationmanager.config.TSAuthorization;
|
|
44
|
+
|
|
40
45
|
import com.transistorsoft.locationmanager.data.LocationModel;
|
|
46
|
+
|
|
41
47
|
import com.transistorsoft.locationmanager.data.SQLQuery;
|
|
42
48
|
import com.transistorsoft.locationmanager.device.DeviceInfo;
|
|
43
49
|
import com.transistorsoft.locationmanager.event.ActivityChangeEvent;
|
|
@@ -46,12 +52,14 @@ import com.transistorsoft.locationmanager.event.ConnectivityChangeEvent;
|
|
|
46
52
|
import com.transistorsoft.locationmanager.event.GeofenceEvent;
|
|
47
53
|
import com.transistorsoft.locationmanager.event.GeofencesChangeEvent;
|
|
48
54
|
import com.transistorsoft.locationmanager.event.HeartbeatEvent;
|
|
55
|
+
import com.transistorsoft.locationmanager.event.LocationEvent;
|
|
49
56
|
import com.transistorsoft.locationmanager.event.LocationProviderChangeEvent;
|
|
50
57
|
import com.transistorsoft.locationmanager.geofence.TSGeofence;
|
|
51
58
|
import com.transistorsoft.locationmanager.http.HttpResponse;
|
|
52
59
|
import com.transistorsoft.locationmanager.http.HttpService;
|
|
60
|
+
import com.transistorsoft.locationmanager.http.TSAuthorization;
|
|
61
|
+
import com.transistorsoft.locationmanager.http.TransistorAuthorizationToken;
|
|
53
62
|
import com.transistorsoft.locationmanager.location.TSCurrentPositionRequest;
|
|
54
|
-
import com.transistorsoft.locationmanager.location.TSLocation;
|
|
55
63
|
import com.transistorsoft.locationmanager.location.TSWatchPositionRequest;
|
|
56
64
|
import com.transistorsoft.locationmanager.scheduler.TSScheduleManager;
|
|
57
65
|
import com.transistorsoft.locationmanager.scheduler.ScheduleEvent;
|
|
@@ -70,7 +78,10 @@ import java.util.Map;
|
|
|
70
78
|
/**
|
|
71
79
|
* Created by chris on 2015-10-30.
|
|
72
80
|
*/
|
|
73
|
-
|
|
81
|
+
@ReactModule(name = "RNBackgroundGeolocation")
|
|
82
|
+
public class RNBackgroundGeolocationModule
|
|
83
|
+
extends NativeRNBackgroundGeolocationSpec
|
|
84
|
+
implements ActivityEventListener, LifecycleEventListener {
|
|
74
85
|
|
|
75
86
|
private static final String TAG = "TSLocationManager";
|
|
76
87
|
private static final String JOB_SERVICE_CLASS = "HeadlessTask";
|
|
@@ -97,26 +108,26 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
97
108
|
reactContext.addLifecycleEventListener(this);
|
|
98
109
|
|
|
99
110
|
TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
100
|
-
config.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
config.setUseCLLocationAccuracy(true);
|
|
112
|
+
Editor ed = config.edit();
|
|
113
|
+
//ed.geo().setUseCLLocationAccuracy(true);
|
|
114
|
+
ed.app().setHeadlessJobService(getClass().getPackage().getName() + "." + JOB_SERVICE_CLASS);
|
|
115
|
+
ed.commit();
|
|
105
116
|
|
|
106
117
|
// These are the only events which can be subscribed to.
|
|
107
|
-
mEvents.add(
|
|
108
|
-
mEvents.add(
|
|
109
|
-
mEvents.add(
|
|
110
|
-
mEvents.add(
|
|
111
|
-
mEvents.add(
|
|
112
|
-
mEvents.add(
|
|
113
|
-
mEvents.add(
|
|
114
|
-
mEvents.add(
|
|
115
|
-
mEvents.add(
|
|
116
|
-
mEvents.add(
|
|
117
|
-
mEvents.add(
|
|
118
|
-
mEvents.add(
|
|
119
|
-
mEvents.add(
|
|
118
|
+
mEvents.add(EventName.LOCATION);
|
|
119
|
+
mEvents.add(EventName.MOTIONCHANGE);
|
|
120
|
+
mEvents.add(EventName.ACTIVITYCHANGE);
|
|
121
|
+
mEvents.add(EventName.PROVIDERCHANGE);
|
|
122
|
+
mEvents.add(EventName.GEOFENCESCHANGE);
|
|
123
|
+
mEvents.add(EventName.GEOFENCE);
|
|
124
|
+
mEvents.add(EventName.HEARTBEAT);
|
|
125
|
+
mEvents.add(EventName.HTTP);
|
|
126
|
+
mEvents.add(EventName.SCHEDULE);
|
|
127
|
+
mEvents.add(EventName.POWERSAVECHANGE);
|
|
128
|
+
mEvents.add(EventName.CONNECTIVITYCHANGE);
|
|
129
|
+
mEvents.add(EventName.ENABLEDCHANGE);
|
|
130
|
+
mEvents.add(EventName.NOTIFICATIONACTION);
|
|
120
131
|
mEvents.add(TSAuthorization.NAME);
|
|
121
132
|
}
|
|
122
133
|
|
|
@@ -131,6 +142,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
131
142
|
|
|
132
143
|
private void registerEvents() {
|
|
133
144
|
BackgroundGeolocation adapter = getAdapter();
|
|
145
|
+
|
|
134
146
|
adapter.onLocation(new LocationCallback());
|
|
135
147
|
adapter.onMotionChange(new MotionChangeCallback());
|
|
136
148
|
adapter.onActivityChange(new ActivityChangeCallback());
|
|
@@ -151,13 +163,11 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
151
163
|
* location event callback
|
|
152
164
|
*/
|
|
153
165
|
private class LocationCallback implements TSLocationCallback {
|
|
154
|
-
@Override
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
} catch (JSONException e) {
|
|
158
|
-
e.printStackTrace();
|
|
159
|
-
}
|
|
166
|
+
@Override
|
|
167
|
+
public void onLocation(LocationEvent locationEvent) {
|
|
168
|
+
sendEvent(EventName.LOCATION, mapToWritableMap(locationEvent.toMap()));
|
|
160
169
|
}
|
|
170
|
+
|
|
161
171
|
@Override public void onError(Integer error) {
|
|
162
172
|
onLocationError(error);
|
|
163
173
|
}
|
|
@@ -167,16 +177,14 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
167
177
|
* motionchange event callback
|
|
168
178
|
*/
|
|
169
179
|
private class MotionChangeCallback implements TSLocationCallback {
|
|
170
|
-
@Override
|
|
180
|
+
@Override
|
|
181
|
+
public void onLocation(LocationEvent locationEvent) {
|
|
171
182
|
WritableMap params = new WritableNativeMap();
|
|
172
|
-
params.putBoolean("isMoving",
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
sendEvent(BackgroundGeolocation.EVENT_MOTIONCHANGE, params);
|
|
176
|
-
} catch (JSONException e) {
|
|
177
|
-
e.printStackTrace();
|
|
178
|
-
}
|
|
183
|
+
params.putBoolean("isMoving", locationEvent.isMoving());
|
|
184
|
+
params.putMap("location", mapToWritableMap(locationEvent.toMap()));
|
|
185
|
+
sendEvent(EventName.MOTIONCHANGE, params);
|
|
179
186
|
}
|
|
187
|
+
|
|
180
188
|
@Override public void onError(Integer error) {
|
|
181
189
|
onLocationError(error);
|
|
182
190
|
}
|
|
@@ -187,11 +195,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
187
195
|
*/
|
|
188
196
|
private class ActivityChangeCallback implements TSActivityChangeCallback {
|
|
189
197
|
@Override public void onActivityChange(ActivityChangeEvent event) {
|
|
190
|
-
|
|
191
|
-
sendEvent(BackgroundGeolocation.EVENT_ACTIVITYCHANGE, jsonToMap(event.toJson()));
|
|
192
|
-
} catch (JSONException e) {
|
|
193
|
-
e.printStackTrace();
|
|
194
|
-
}
|
|
198
|
+
sendEvent(EventName.ACTIVITYCHANGE, mapToWritableMap(event.toMap()));
|
|
195
199
|
}
|
|
196
200
|
}
|
|
197
201
|
|
|
@@ -206,7 +210,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
206
210
|
params.putBoolean("enabled", event.isEnabled());
|
|
207
211
|
params.putInt("accuracyAuthorization", event.getAccuracyAuthorization());
|
|
208
212
|
params.putInt("status", event.getStatus());
|
|
209
|
-
sendEvent(
|
|
213
|
+
sendEvent(EventName.PROVIDERCHANGE, params);
|
|
210
214
|
}
|
|
211
215
|
}
|
|
212
216
|
|
|
@@ -217,7 +221,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
217
221
|
@Override public void onConnectivityChange(ConnectivityChangeEvent event) {
|
|
218
222
|
WritableMap params = new WritableNativeMap();
|
|
219
223
|
params.putBoolean("connected", event.hasConnection());
|
|
220
|
-
sendEvent(
|
|
224
|
+
sendEvent(EventName.CONNECTIVITYCHANGE, params);
|
|
221
225
|
}
|
|
222
226
|
}
|
|
223
227
|
/**
|
|
@@ -225,7 +229,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
225
229
|
*/
|
|
226
230
|
private class EnabledChangeCallback implements TSEnabledChangeCallback {
|
|
227
231
|
@Override public void onEnabledChange(boolean enabled) {
|
|
228
|
-
sendEvent(
|
|
232
|
+
sendEvent(EventName.ENABLEDCHANGE, enabled);
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
/**
|
|
@@ -233,7 +237,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
233
237
|
*/
|
|
234
238
|
private class NotificationActionCallback implements TSNotificationActionCallback {
|
|
235
239
|
@Override public void onClick(String buttonId) {
|
|
236
|
-
sendEvent(
|
|
240
|
+
sendEvent(EventName.NOTIFICATIONACTION, buttonId);
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
/**
|
|
@@ -241,15 +245,11 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
241
245
|
*/
|
|
242
246
|
private class GeofencesChangeCallback implements TSGeofencesChangeCallback {
|
|
243
247
|
@Override public void onGeofencesChange(GeofencesChangeEvent event) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
sendEvent(BackgroundGeolocation.EVENT_GEOFENCESCHANGE, jsonToMap(event.toJson()));
|
|
250
|
-
} catch (JSONException e) {
|
|
251
|
-
e.printStackTrace();
|
|
252
|
-
}
|
|
248
|
+
// TODO
|
|
249
|
+
WritableMap params = new WritableNativeMap();
|
|
250
|
+
WritableArray on = new WritableNativeArray();
|
|
251
|
+
WritableArray off = new WritableNativeArray();
|
|
252
|
+
sendEvent(EventName.GEOFENCESCHANGE, mapToWritableMap(event.toMap()));
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -258,11 +258,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
258
258
|
*/
|
|
259
259
|
private class GeofenceCallback implements TSGeofenceCallback {
|
|
260
260
|
@Override public void onGeofence(GeofenceEvent event) {
|
|
261
|
-
|
|
262
|
-
sendEvent(BackgroundGeolocation.EVENT_GEOFENCE, jsonToMap(event.toJson()));
|
|
263
|
-
} catch (JSONException e) {
|
|
264
|
-
e.printStackTrace();
|
|
265
|
-
}
|
|
261
|
+
sendEvent(EventName.GEOFENCE, mapToWritableMap(event.toMap()));
|
|
266
262
|
}
|
|
267
263
|
}
|
|
268
264
|
|
|
@@ -271,11 +267,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
271
267
|
*/
|
|
272
268
|
private class HeartbeatCallback implements TSHeartbeatCallback {
|
|
273
269
|
@Override public void onHeartbeat(HeartbeatEvent event) {
|
|
274
|
-
|
|
275
|
-
sendEvent(BackgroundGeolocation.EVENT_HEARTBEAT, jsonToMap(event.toJson()));
|
|
276
|
-
} catch (JSONException e) {
|
|
277
|
-
e.printStackTrace();
|
|
278
|
-
}
|
|
270
|
+
sendEvent(EventName.HEARTBEAT, mapToWritableMap(event.toMap()));
|
|
279
271
|
}
|
|
280
272
|
}
|
|
281
273
|
|
|
@@ -288,7 +280,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
288
280
|
params.putBoolean("success", response.isSuccess());
|
|
289
281
|
params.putInt("status", response.status);
|
|
290
282
|
params.putString("responseText", response.responseText);
|
|
291
|
-
sendEvent(
|
|
283
|
+
sendEvent(EventName.HTTP, params);
|
|
292
284
|
}
|
|
293
285
|
}
|
|
294
286
|
|
|
@@ -297,11 +289,8 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
297
289
|
*/
|
|
298
290
|
private class ScheduleCallback implements TSScheduleCallback {
|
|
299
291
|
@Override public void onSchedule(ScheduleEvent event) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
} catch (JSONException e) {
|
|
303
|
-
e.printStackTrace();
|
|
304
|
-
}
|
|
292
|
+
TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
293
|
+
sendEvent(EventName.SCHEDULE, mapToWritableMap(config.toMap(false)));
|
|
305
294
|
}
|
|
306
295
|
}
|
|
307
296
|
|
|
@@ -310,7 +299,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
310
299
|
*/
|
|
311
300
|
private class PowerSaveChangeCallack implements TSPowerSaveChangeCallback {
|
|
312
301
|
@Override public void onPowerSaveChange(Boolean isPowerSaveMode) {
|
|
313
|
-
sendEvent(
|
|
302
|
+
sendEvent(EventName.POWERSAVECHANGE, isPowerSaveMode);
|
|
314
303
|
}
|
|
315
304
|
}
|
|
316
305
|
|
|
@@ -319,11 +308,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
319
308
|
*/
|
|
320
309
|
private class AuthorizationCallback implements TSAuthorizationCallback {
|
|
321
310
|
@Override public void onResponse(AuthorizationEvent event) {
|
|
322
|
-
|
|
323
|
-
sendEvent(TSAuthorization.NAME, jsonToMap(event.toJson()));
|
|
324
|
-
} catch (JSONException e) {
|
|
325
|
-
TSLog.logger.error(TSLog.error(e.getMessage()), e);
|
|
326
|
-
}
|
|
311
|
+
sendEvent(TSAuthorization.NAME, mapToWritableMap(event.toMap()));
|
|
327
312
|
}
|
|
328
313
|
}
|
|
329
314
|
|
|
@@ -371,7 +356,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
371
356
|
}
|
|
372
357
|
|
|
373
358
|
@ReactMethod
|
|
374
|
-
public void ready(ReadableMap params, final
|
|
359
|
+
public void ready(ReadableMap params, final Promise response) {
|
|
375
360
|
TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
376
361
|
|
|
377
362
|
boolean reset = true;
|
|
@@ -381,11 +366,11 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
381
366
|
|
|
382
367
|
if (mReady) {
|
|
383
368
|
if (reset) {
|
|
384
|
-
TSLog.
|
|
385
|
-
setConfig(params,
|
|
369
|
+
TSLog.w(TSLog.warn("#ready already called. Redirecting to #setConfig"));
|
|
370
|
+
setConfig(params, response);
|
|
386
371
|
} else {
|
|
387
|
-
TSLog.
|
|
388
|
-
|
|
372
|
+
TSLog.w(TSLog.warn("#ready already called. Ignored config since reset: false"));
|
|
373
|
+
response.resolve(getState());
|
|
389
374
|
}
|
|
390
375
|
return;
|
|
391
376
|
}
|
|
@@ -405,99 +390,99 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
405
390
|
// Have to be careful with expires: ReadadbleMap#toHashMap converts it to Double.
|
|
406
391
|
options.put(TSAuthorization.FIELD_EXPIRES, readableMap.getInt(TSAuthorization.FIELD_EXPIRES));
|
|
407
392
|
|
|
408
|
-
config.
|
|
409
|
-
|
|
410
|
-
|
|
393
|
+
Editor ed = config.edit();
|
|
394
|
+
ed.auth().setAuthorization(options);
|
|
395
|
+
ed.commit();
|
|
411
396
|
}
|
|
412
397
|
}
|
|
413
398
|
}
|
|
414
399
|
getAdapter().ready(new TSCallback() {
|
|
415
|
-
@Override public void onSuccess() {
|
|
416
|
-
@Override public void onFailure(String error) {
|
|
400
|
+
@Override public void onSuccess() { response.resolve(getState()); }
|
|
401
|
+
@Override public void onFailure(String error) { response.reject(error); }
|
|
417
402
|
});
|
|
418
403
|
}
|
|
419
404
|
|
|
420
405
|
@ReactMethod
|
|
421
|
-
public void configure(ReadableMap params, final
|
|
406
|
+
public void configure(ReadableMap params, final Promise response){
|
|
422
407
|
final TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
423
408
|
config.reset();
|
|
424
409
|
config.updateWithJSONObject(mapToJson(setHeadlessJobService(params)));
|
|
425
410
|
|
|
426
411
|
getAdapter().ready(new TSCallback() {
|
|
427
|
-
@Override public void onSuccess() {
|
|
428
|
-
@Override public void onFailure(String error) {
|
|
412
|
+
@Override public void onSuccess() { response.resolve(getState()); }
|
|
413
|
+
@Override public void onFailure(String error) { response.reject(error); }
|
|
429
414
|
});
|
|
430
415
|
}
|
|
431
416
|
|
|
432
417
|
@ReactMethod
|
|
433
|
-
public void setConfig(ReadableMap params, final
|
|
418
|
+
public void setConfig(ReadableMap params, final Promise response) {
|
|
434
419
|
TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
435
420
|
config.updateWithJSONObject(mapToJson(params));
|
|
436
|
-
|
|
421
|
+
response.resolve(getState());
|
|
437
422
|
}
|
|
438
423
|
|
|
439
424
|
@ReactMethod
|
|
440
|
-
public void reset(ReadableMap defaultConfig, final
|
|
425
|
+
public void reset(ReadableMap defaultConfig, final Promise response) {
|
|
441
426
|
TSConfig config = TSConfig.getInstance(getReactApplicationContext());
|
|
442
427
|
config.reset();
|
|
443
428
|
config.updateWithJSONObject(mapToJson(setHeadlessJobService(defaultConfig)));
|
|
444
|
-
|
|
429
|
+
response.resolve(getState());
|
|
445
430
|
}
|
|
446
431
|
|
|
447
432
|
@ReactMethod
|
|
448
|
-
public void start(final
|
|
433
|
+
public void start(final Promise response) {
|
|
449
434
|
getAdapter().start(new TSCallback() {
|
|
450
|
-
@Override public void onSuccess() {
|
|
451
|
-
@Override public void onFailure(String error) {
|
|
435
|
+
@Override public void onSuccess() { response.resolve(getState()); }
|
|
436
|
+
@Override public void onFailure(String error) { response.reject(error); }
|
|
452
437
|
});
|
|
453
438
|
}
|
|
454
439
|
|
|
455
440
|
@ReactMethod
|
|
456
|
-
public void startSchedule(
|
|
441
|
+
public void startSchedule(Promise response) {
|
|
457
442
|
if (getAdapter().startSchedule()) {
|
|
458
|
-
|
|
443
|
+
response.resolve(getState());
|
|
459
444
|
} else {
|
|
460
|
-
|
|
445
|
+
response.reject("Failed to start schedule. Did you configure a #schedule?");
|
|
461
446
|
}
|
|
462
447
|
}
|
|
463
448
|
|
|
464
449
|
@ReactMethod
|
|
465
|
-
public void stopSchedule(
|
|
450
|
+
public void stopSchedule(Promise response) {
|
|
466
451
|
getAdapter().stopSchedule();
|
|
467
|
-
|
|
452
|
+
response.resolve(getState());
|
|
468
453
|
}
|
|
469
454
|
|
|
470
455
|
@ReactMethod
|
|
471
|
-
public void startGeofences(final
|
|
456
|
+
public void startGeofences(final Promise response) {
|
|
472
457
|
getAdapter().startGeofences(new TSCallback() {
|
|
473
|
-
@Override public void onSuccess() {
|
|
474
|
-
@Override public void onFailure(String error) {
|
|
458
|
+
@Override public void onSuccess() { response.resolve(getState()); }
|
|
459
|
+
@Override public void onFailure(String error) { response.reject(error); }
|
|
475
460
|
});
|
|
476
461
|
}
|
|
477
462
|
|
|
478
463
|
@ReactMethod
|
|
479
|
-
public void stop(final
|
|
464
|
+
public void stop(final Promise response) {
|
|
480
465
|
getAdapter().stop(new TSCallback() {
|
|
481
|
-
@Override public void onSuccess() {
|
|
482
|
-
@Override public void onFailure(String error) {
|
|
466
|
+
@Override public void onSuccess() { response.resolve(getState()); }
|
|
467
|
+
@Override public void onFailure(String error) { response.reject(error); }
|
|
483
468
|
});
|
|
484
469
|
}
|
|
485
470
|
|
|
486
471
|
@ReactMethod
|
|
487
|
-
public void changePace(
|
|
472
|
+
public void changePace(final boolean moving, final Promise response) {
|
|
488
473
|
getAdapter().changePace(moving, new TSCallback() {
|
|
489
|
-
@Override public void onSuccess() {
|
|
490
|
-
@Override public void onFailure(String error) {
|
|
474
|
+
@Override public void onSuccess() { response.resolve(moving); }
|
|
475
|
+
@Override public void onFailure(String error) { response.reject(error); }
|
|
491
476
|
});
|
|
492
477
|
}
|
|
493
478
|
|
|
494
479
|
@ReactMethod
|
|
495
|
-
public void getState(
|
|
496
|
-
|
|
480
|
+
public void getState(Promise response) {
|
|
481
|
+
response.resolve(getState());
|
|
497
482
|
}
|
|
498
483
|
|
|
499
484
|
@ReactMethod
|
|
500
|
-
public void getLocations(final
|
|
485
|
+
public void getLocations(final Promise response) {
|
|
501
486
|
getAdapter().getLocations(new TSGetLocationsCallback() {
|
|
502
487
|
@Override public void onSuccess(List<LocationModel> records) {
|
|
503
488
|
try {
|
|
@@ -505,73 +490,75 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
505
490
|
for (LocationModel location : records) {
|
|
506
491
|
data.put(location.json);
|
|
507
492
|
}
|
|
508
|
-
|
|
493
|
+
response.resolve(convertJsonToArray(data));
|
|
509
494
|
} catch (JSONException e) {
|
|
510
495
|
e.printStackTrace();
|
|
511
|
-
|
|
496
|
+
response.reject(e.getMessage());
|
|
512
497
|
}
|
|
513
498
|
}
|
|
514
|
-
@Override public void onFailure(Integer error) {
|
|
499
|
+
@Override public void onFailure(Integer error) { response.reject(error.toString()); }
|
|
515
500
|
});
|
|
516
501
|
}
|
|
517
502
|
|
|
518
503
|
@ReactMethod
|
|
519
|
-
public void getCount(final
|
|
520
|
-
|
|
504
|
+
public void getCount(final Promise response) {
|
|
505
|
+
response.resolve(getAdapter().getCount());
|
|
521
506
|
}
|
|
522
507
|
|
|
523
508
|
@ReactMethod
|
|
524
|
-
public void insertLocation(ReadableMap params, final
|
|
509
|
+
public void insertLocation(ReadableMap params, final Promise response) {
|
|
525
510
|
getAdapter().insertLocation(mapToJson(params), new TSInsertLocationCallback() {
|
|
526
511
|
@Override public void onSuccess(String uuid) {
|
|
527
|
-
|
|
512
|
+
response.resolve(uuid);
|
|
528
513
|
}
|
|
529
514
|
@Override public void onFailure(String error) {
|
|
530
|
-
|
|
515
|
+
response.reject(error);
|
|
531
516
|
}
|
|
532
517
|
});
|
|
533
518
|
}
|
|
534
519
|
|
|
535
520
|
// @deprecated -> #destroyLocations
|
|
536
521
|
@ReactMethod
|
|
537
|
-
public void clearDatabase(
|
|
538
|
-
destroyLocations(
|
|
522
|
+
public void clearDatabase(Promise response) {
|
|
523
|
+
destroyLocations(response);
|
|
539
524
|
}
|
|
540
525
|
|
|
541
526
|
@ReactMethod
|
|
542
|
-
public void destroyLocations(final
|
|
527
|
+
public void destroyLocations(final Promise response) {
|
|
543
528
|
getAdapter().destroyLocations(new TSCallback() {
|
|
544
|
-
@Override public void onSuccess() {
|
|
529
|
+
@Override public void onSuccess() {
|
|
530
|
+
response.resolve(true);
|
|
531
|
+
}
|
|
545
532
|
@Override public void onFailure(String error) {
|
|
546
|
-
|
|
533
|
+
response.reject(error);
|
|
547
534
|
}
|
|
548
535
|
});
|
|
549
536
|
}
|
|
550
537
|
|
|
551
538
|
@ReactMethod
|
|
552
|
-
public void destroyLocation(String uuid, final
|
|
539
|
+
public void destroyLocation(String uuid, final Promise response) {
|
|
553
540
|
getAdapter().destroyLocation(uuid, new TSCallback() {
|
|
554
|
-
@Override public void onSuccess() {
|
|
541
|
+
@Override public void onSuccess() { response.resolve(true); }
|
|
555
542
|
@Override public void onFailure(String error) {
|
|
556
|
-
|
|
543
|
+
response.reject(error);
|
|
557
544
|
}
|
|
558
545
|
});
|
|
559
546
|
}
|
|
560
547
|
|
|
561
548
|
@ReactMethod
|
|
562
|
-
public void destroyLog(final
|
|
549
|
+
public void destroyLog(final Promise response) {
|
|
563
550
|
getAdapter().destroyLog(new TSCallback() {
|
|
564
551
|
@Override public void onSuccess() {
|
|
565
|
-
|
|
552
|
+
response.resolve(true);
|
|
566
553
|
}
|
|
567
554
|
@Override public void onFailure(String error) {
|
|
568
|
-
|
|
555
|
+
response.reject(error);
|
|
569
556
|
}
|
|
570
557
|
});
|
|
571
558
|
}
|
|
572
559
|
|
|
573
560
|
@ReactMethod
|
|
574
|
-
public void sync(final
|
|
561
|
+
public void sync(final Promise response) {
|
|
575
562
|
getAdapter().sync(new TSSyncCallback() {
|
|
576
563
|
@Override public void onSuccess(List<LocationModel> records) {
|
|
577
564
|
try {
|
|
@@ -579,31 +566,27 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
579
566
|
for (LocationModel location : records) {
|
|
580
567
|
data.put(location.json);
|
|
581
568
|
}
|
|
582
|
-
|
|
569
|
+
response.resolve(convertJsonToArray(data));
|
|
583
570
|
} catch (JSONException e) {
|
|
584
|
-
|
|
571
|
+
response.reject(e.getMessage());
|
|
585
572
|
}
|
|
586
573
|
}
|
|
587
574
|
@Override public void onFailure(String error) {
|
|
588
|
-
|
|
575
|
+
response.reject(error);
|
|
589
576
|
}
|
|
590
577
|
});
|
|
591
578
|
}
|
|
592
579
|
|
|
593
580
|
@ReactMethod
|
|
594
|
-
public void getCurrentPosition(ReadableMap options, final
|
|
581
|
+
public void getCurrentPosition(ReadableMap options, final Promise response) {
|
|
595
582
|
TSCurrentPositionRequest.Builder builder = new TSCurrentPositionRequest.Builder(getReactApplicationContext());
|
|
596
583
|
|
|
597
584
|
builder.setCallback(new TSLocationCallback() {
|
|
598
|
-
@Override public void onLocation(
|
|
599
|
-
|
|
600
|
-
success.invoke(jsonToMap(tsLocation.toJson()));
|
|
601
|
-
} catch (JSONException e) {
|
|
602
|
-
failure.invoke(e.getMessage());
|
|
603
|
-
}
|
|
585
|
+
@Override public void onLocation(LocationEvent event) {
|
|
586
|
+
response.resolve(mapToWritableMap(event.toMap()));
|
|
604
587
|
}
|
|
605
588
|
@Override public void onError(Integer errorCode) {
|
|
606
|
-
|
|
589
|
+
response.reject(errorCode.toString());
|
|
607
590
|
}
|
|
608
591
|
});
|
|
609
592
|
|
|
@@ -617,19 +600,15 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
617
600
|
getAdapter().getCurrentPosition(builder.build());
|
|
618
601
|
}
|
|
619
602
|
@ReactMethod
|
|
620
|
-
public void watchPosition(ReadableMap options, final
|
|
603
|
+
public void watchPosition(ReadableMap options, final Promise response) {
|
|
621
604
|
TSWatchPositionRequest.Builder builder = new TSWatchPositionRequest.Builder(getReactApplicationContext());
|
|
622
605
|
|
|
623
606
|
builder.setCallback(new TSLocationCallback() {
|
|
624
|
-
@Override public void onLocation(
|
|
625
|
-
|
|
626
|
-
sendEvent(EVENT_WATCHPOSITION, jsonToMap(tsLocation.toJson()));
|
|
627
|
-
} catch (JSONException e) {
|
|
628
|
-
e.printStackTrace();
|
|
629
|
-
}
|
|
607
|
+
@Override public void onLocation(LocationEvent event) {
|
|
608
|
+
sendEvent(EVENT_WATCHPOSITION, mapToWritableMap(event.toMap()));
|
|
630
609
|
}
|
|
631
610
|
@Override public void onError(Integer error) {
|
|
632
|
-
|
|
611
|
+
response.reject(error.toString());
|
|
633
612
|
}
|
|
634
613
|
});
|
|
635
614
|
|
|
@@ -639,68 +618,66 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
639
618
|
if (options.hasKey("desiredAccuracy")) { builder.setDesiredAccuracy(options.getInt("desiredAccuracy")); }
|
|
640
619
|
|
|
641
620
|
getAdapter().watchPosition(builder.build());
|
|
642
|
-
|
|
621
|
+
// TODO Implement watchId for android.
|
|
622
|
+
response.resolve(-1);
|
|
643
623
|
}
|
|
644
624
|
@ReactMethod
|
|
645
|
-
public void stopWatchPosition(
|
|
625
|
+
public void stopWatchPosition(double watchId, final Promise response) {
|
|
626
|
+
// TODO Implement watchId for android.
|
|
646
627
|
getAdapter().stopWatchPosition(new TSCallback() {
|
|
647
628
|
@Override public void onSuccess() {
|
|
648
|
-
|
|
629
|
+
response.resolve(true);
|
|
649
630
|
}
|
|
650
631
|
@Override public void onFailure(String error) {
|
|
651
|
-
|
|
632
|
+
response.reject(error);
|
|
652
633
|
}
|
|
653
634
|
});
|
|
654
635
|
}
|
|
655
636
|
@ReactMethod
|
|
656
|
-
public void getOdometer(
|
|
657
|
-
|
|
637
|
+
public void getOdometer(final Promise response) {
|
|
638
|
+
response.resolve(getAdapter().getOdometer());
|
|
658
639
|
}
|
|
659
640
|
@ReactMethod
|
|
660
|
-
public void setOdometer(
|
|
641
|
+
public void setOdometer(double value, final Promise response) {
|
|
661
642
|
getAdapter().setOdometer(value, new TSLocationCallback() {
|
|
662
|
-
@Override public void onLocation(
|
|
663
|
-
|
|
664
|
-
success.invoke(jsonToMap(location.toJson()));
|
|
665
|
-
} catch (JSONException e) {
|
|
666
|
-
failure.invoke(e.getMessage());
|
|
667
|
-
}
|
|
643
|
+
@Override public void onLocation(LocationEvent event) {
|
|
644
|
+
response.resolve(mapToWritableMap(event.toMap()));
|
|
668
645
|
}
|
|
669
646
|
@Override public void onError(Integer errorCode) {
|
|
670
|
-
|
|
647
|
+
response.reject(errorCode.toString());
|
|
671
648
|
}
|
|
672
649
|
});
|
|
673
650
|
}
|
|
674
651
|
@ReactMethod
|
|
675
|
-
public void addGeofence(ReadableMap options, final
|
|
652
|
+
public void addGeofence(ReadableMap options, final Promise response) {
|
|
676
653
|
try {
|
|
677
654
|
getAdapter().addGeofence(buildGeofence(options), new TSCallback() {
|
|
678
|
-
@Override public void onSuccess() {
|
|
679
|
-
@Override public void onFailure(String error) {
|
|
655
|
+
@Override public void onSuccess() { response.resolve(true); }
|
|
656
|
+
@Override public void onFailure(String error) { response.reject(error); }
|
|
680
657
|
});
|
|
681
658
|
} catch (TSGeofence.Exception e) {
|
|
682
|
-
|
|
659
|
+
response.reject(e.getMessage());
|
|
683
660
|
}
|
|
684
661
|
}
|
|
685
662
|
|
|
686
663
|
@ReactMethod
|
|
687
|
-
public void addGeofences(ReadableArray data, final
|
|
664
|
+
public void addGeofences(ReadableArray data, final Promise response) {
|
|
688
665
|
List<TSGeofence> geofences = new ArrayList<TSGeofence>();
|
|
689
666
|
for (int n=0;n<data.size();n++) {
|
|
690
667
|
try {
|
|
691
668
|
geofences.add(buildGeofence(data.getMap(n)));
|
|
692
669
|
} catch (TSGeofence.Exception e) {
|
|
693
|
-
|
|
670
|
+
response.reject(e.getMessage());
|
|
694
671
|
return;
|
|
695
672
|
}
|
|
696
673
|
}
|
|
697
674
|
|
|
698
675
|
getAdapter().addGeofences(geofences, new TSCallback() {
|
|
699
676
|
@Override public void onSuccess() {
|
|
700
|
-
|
|
677
|
+
response.resolve(true);
|
|
701
678
|
}
|
|
702
679
|
@Override public void onFailure(String error) {
|
|
703
|
-
|
|
680
|
+
response.reject(error);
|
|
704
681
|
}
|
|
705
682
|
});
|
|
706
683
|
}
|
|
@@ -736,83 +713,73 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
736
713
|
}
|
|
737
714
|
|
|
738
715
|
@ReactMethod
|
|
739
|
-
public void removeGeofence(String identifier, final
|
|
716
|
+
public void removeGeofence(String identifier, final Promise response) {
|
|
740
717
|
getAdapter().removeGeofence(identifier, new TSCallback() {
|
|
741
718
|
@Override public void onSuccess() {
|
|
742
|
-
|
|
719
|
+
response.resolve(true);
|
|
743
720
|
}
|
|
744
721
|
@Override public void onFailure(String error) {
|
|
745
|
-
|
|
722
|
+
response.reject(error);
|
|
746
723
|
}
|
|
747
724
|
});
|
|
748
725
|
}
|
|
749
726
|
|
|
750
727
|
@ReactMethod
|
|
751
|
-
public void removeGeofences(final
|
|
728
|
+
public void removeGeofences(final Promise response) {
|
|
752
729
|
// TODO allow JS api to delete a list-of-geofences.
|
|
753
730
|
// TODO accept WritableArray geofences from Client js API, allowing to remove a set of geofences
|
|
754
731
|
List<String> identifiers = new ArrayList<>();
|
|
755
732
|
getAdapter().removeGeofences(identifiers, new TSCallback() {
|
|
756
733
|
@Override public void onSuccess() {
|
|
757
|
-
|
|
734
|
+
response.resolve(true);
|
|
758
735
|
}
|
|
759
736
|
@Override public void onFailure(String error) {
|
|
760
|
-
|
|
737
|
+
response.reject(error);
|
|
761
738
|
}
|
|
762
739
|
});
|
|
763
740
|
}
|
|
764
741
|
|
|
765
742
|
@ReactMethod
|
|
766
|
-
public void getGeofences(final
|
|
743
|
+
public void getGeofences(final Promise response) {
|
|
767
744
|
getAdapter().getGeofences(new TSGetGeofencesCallback() {
|
|
768
745
|
@Override public void onSuccess(List<TSGeofence> geofences) {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
rs.pushMap(jsonToMap(geofence.toJson()));
|
|
773
|
-
}
|
|
774
|
-
success.invoke(rs);
|
|
775
|
-
} catch (JSONException e) {
|
|
776
|
-
e.printStackTrace();
|
|
777
|
-
failure.invoke(e.getMessage());
|
|
746
|
+
WritableArray rs = new WritableNativeArray();
|
|
747
|
+
for (TSGeofence geofence : geofences) {
|
|
748
|
+
rs.pushMap(mapToWritableMap(geofence.toMap()));
|
|
778
749
|
}
|
|
750
|
+
response.resolve(rs);
|
|
779
751
|
}
|
|
780
|
-
@Override public void onFailure(String error) {
|
|
752
|
+
@Override public void onFailure(String error) { response.reject(error); }
|
|
781
753
|
});
|
|
782
754
|
}
|
|
783
755
|
|
|
784
756
|
@ReactMethod
|
|
785
|
-
public void getGeofence(String identifier, final
|
|
757
|
+
public void getGeofence(String identifier, final Promise response) {
|
|
786
758
|
getAdapter().getGeofence(identifier, new TSGetGeofenceCallback() {
|
|
787
759
|
@Override public void onSuccess(TSGeofence geofence) {
|
|
788
|
-
|
|
789
|
-
success.invoke(jsonToMap(geofence.toJson()));
|
|
790
|
-
} catch (JSONException e) {
|
|
791
|
-
e.printStackTrace();
|
|
792
|
-
failure.invoke(e.getMessage());
|
|
793
|
-
}
|
|
760
|
+
response.resolve(mapToWritableMap(geofence.toMap()));
|
|
794
761
|
}
|
|
795
762
|
@Override public void onFailure(String error) {
|
|
796
|
-
|
|
763
|
+
response.reject(error);
|
|
797
764
|
}
|
|
798
765
|
});
|
|
799
766
|
}
|
|
800
767
|
|
|
801
768
|
@ReactMethod
|
|
802
|
-
public void geofenceExists(String identifier, final
|
|
769
|
+
public void geofenceExists(String identifier, final Promise response) {
|
|
803
770
|
getAdapter().geofenceExists(identifier, new TSGeofenceExistsCallback() {
|
|
804
771
|
@Override public void onResult(boolean exists) {
|
|
805
|
-
|
|
772
|
+
response.resolve(exists);
|
|
806
773
|
}
|
|
807
774
|
});
|
|
808
775
|
}
|
|
809
776
|
|
|
810
777
|
// TODO Rename #beginBackgroundTask -> #startBackgroundTask
|
|
811
778
|
@ReactMethod
|
|
812
|
-
public void beginBackgroundTask(final
|
|
779
|
+
public void beginBackgroundTask(final Promise response) {
|
|
813
780
|
getAdapter().startBackgroundTask(new TSBackgroundTaskCallback() {
|
|
814
781
|
@Override public void onStart(int taskId) {
|
|
815
|
-
|
|
782
|
+
response.resolve(taskId);
|
|
816
783
|
}
|
|
817
784
|
@Override public void onCancel(int taskId) { } // NO IMPLEMENTATION
|
|
818
785
|
});
|
|
@@ -820,115 +787,111 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
820
787
|
|
|
821
788
|
// TODO Rename #finish -> #stopBackgroundTask
|
|
822
789
|
@ReactMethod
|
|
823
|
-
public void finish(
|
|
824
|
-
getAdapter().stopBackgroundTask(taskId);
|
|
825
|
-
|
|
790
|
+
public void finish(double taskId, Promise response) {
|
|
791
|
+
getAdapter().stopBackgroundTask((int) taskId);
|
|
792
|
+
response.resolve(taskId);
|
|
826
793
|
}
|
|
827
794
|
|
|
828
795
|
/**
|
|
829
796
|
* Called by user's registered HeadlessTask when they call BackgroundGeolocation.finishHeadlessTask(event.taskId)
|
|
830
|
-
* @param taskId
|
|
831
|
-
* @param success
|
|
832
|
-
* @param failure
|
|
797
|
+
* @param taskId*
|
|
833
798
|
*/
|
|
834
799
|
@ReactMethod
|
|
835
|
-
public void finishHeadlessTask(
|
|
800
|
+
public void finishHeadlessTask(double taskId, Promise response) {
|
|
836
801
|
EventBus eventBus = EventBus.getDefault();
|
|
837
802
|
if (!eventBus.hasSubscriberForEvent(HeadlessEvent.class)) {
|
|
838
803
|
// This shouldn't happen. In order for this method to even be called, it MUST have been executed from within the consumer's
|
|
839
804
|
// registered HeadlessTask. In order for that headless-task to have even be called, HeadlessEvent MUST have been registered with EventBus.
|
|
840
805
|
String message = "finishHeadlessTask failed to find an EventBus subscriber for HeadlessEvent";
|
|
841
|
-
TSLog.
|
|
842
|
-
|
|
806
|
+
TSLog.e(TSLog.warn(message));
|
|
807
|
+
response.reject(message);
|
|
843
808
|
return;
|
|
844
809
|
}
|
|
845
|
-
FinishHeadlessTaskEvent event = new FinishHeadlessTaskEvent(getReactApplicationContext(), taskId);
|
|
810
|
+
FinishHeadlessTaskEvent event = new FinishHeadlessTaskEvent(getReactApplicationContext(), (int) taskId);
|
|
846
811
|
eventBus.post(event);
|
|
847
|
-
|
|
812
|
+
response.resolve(true);
|
|
848
813
|
}
|
|
849
814
|
|
|
850
815
|
@ReactMethod
|
|
851
|
-
public void getTransistorToken(String orgname, String username, String url, final
|
|
816
|
+
public void getTransistorToken(String orgname, String username, String url, final Promise response) {
|
|
852
817
|
|
|
853
818
|
TransistorAuthorizationToken.findOrCreate(getReactApplicationContext(), orgname, username, url, new TransistorAuthorizationToken.Callback() {
|
|
854
819
|
@Override public void onSuccess(TransistorAuthorizationToken token) {
|
|
855
|
-
|
|
856
|
-
success.invoke(jsonToMap(token.toJson()));
|
|
857
|
-
} catch (JSONException e) {
|
|
858
|
-
failure.invoke(e.getMessage());
|
|
859
|
-
}
|
|
820
|
+
response.resolve(mapToWritableMap(token.toMap()));
|
|
860
821
|
}
|
|
861
822
|
@Override public void onFailure(String error) {
|
|
862
823
|
WritableMap params = new WritableNativeMap();
|
|
863
824
|
params.putString("status", error);
|
|
864
825
|
params.putString("message", error);
|
|
865
|
-
|
|
826
|
+
response.reject(error);
|
|
866
827
|
}
|
|
867
828
|
});
|
|
868
829
|
}
|
|
869
830
|
|
|
870
831
|
@ReactMethod
|
|
871
|
-
public void destroyTransistorToken(String url, final
|
|
832
|
+
public void destroyTransistorToken(String url, final Promise response) {
|
|
872
833
|
TransistorAuthorizationToken.destroyTokenForUrl(getReactApplicationContext(), url, new TSCallback() {
|
|
873
834
|
@Override public void onSuccess() {
|
|
874
|
-
|
|
835
|
+
response.resolve(true);
|
|
875
836
|
}
|
|
876
837
|
@Override public void onFailure(String error) {
|
|
877
|
-
|
|
838
|
+
response.reject(error);
|
|
878
839
|
}
|
|
879
840
|
});
|
|
880
841
|
}
|
|
881
842
|
|
|
882
843
|
@ReactMethod
|
|
883
|
-
public void playSound(String soundId) {
|
|
844
|
+
public void playSound(String soundId, Promise response) {
|
|
884
845
|
getAdapter().startTone(soundId);
|
|
846
|
+
response.resolve(true);
|
|
885
847
|
}
|
|
886
848
|
|
|
887
849
|
@ReactMethod
|
|
888
|
-
public void getLog(ReadableMap params, final
|
|
850
|
+
public void getLog(ReadableMap params, final Promise response) {
|
|
889
851
|
SQLQuery query = parseSQLQuery(params);
|
|
890
852
|
|
|
891
853
|
TSLog.getLog(query, new TSGetLogCallback() {
|
|
892
854
|
@Override public void onSuccess(String log) {
|
|
893
|
-
|
|
855
|
+
response.resolve(log);
|
|
894
856
|
}
|
|
895
857
|
@Override public void onFailure(String error) {
|
|
896
|
-
|
|
858
|
+
response.reject(error);
|
|
897
859
|
}
|
|
898
860
|
});
|
|
899
861
|
}
|
|
900
862
|
|
|
901
863
|
@ReactMethod
|
|
902
|
-
public void emailLog(String email, ReadableMap params, final
|
|
864
|
+
public void emailLog(String email, ReadableMap params, final Promise response) {
|
|
903
865
|
SQLQuery query = parseSQLQuery(params);
|
|
904
866
|
|
|
905
867
|
TSLog.emailLog(getCurrentActivity(), email, query, new TSEmailLogCallback() {
|
|
906
868
|
@Override public void onSuccess() {
|
|
907
|
-
|
|
869
|
+
response.resolve(true);
|
|
908
870
|
}
|
|
909
871
|
@Override public void onFailure(String error) {
|
|
910
|
-
|
|
872
|
+
response.reject(error);
|
|
911
873
|
}
|
|
912
874
|
});
|
|
913
875
|
}
|
|
914
876
|
|
|
915
877
|
@ReactMethod
|
|
916
|
-
public void uploadLog(String url, ReadableMap params, final
|
|
878
|
+
public void uploadLog(String url, ReadableMap params, final Promise response) {
|
|
917
879
|
SQLQuery query = parseSQLQuery(params);
|
|
918
880
|
|
|
919
881
|
TSLog.uploadLog(getReactApplicationContext(), url, query, new TSCallback() {
|
|
920
882
|
@Override public void onSuccess() {
|
|
921
|
-
|
|
883
|
+
response.resolve(true);
|
|
922
884
|
}
|
|
923
885
|
@Override public void onFailure(String error) {
|
|
924
|
-
|
|
886
|
+
response.reject(error);
|
|
925
887
|
}
|
|
926
888
|
});
|
|
927
889
|
}
|
|
928
890
|
|
|
929
891
|
@ReactMethod
|
|
930
|
-
public void log(String level, String message
|
|
892
|
+
public void log(String level, String message, Promise response) {
|
|
931
893
|
TSLog.log(level, message);
|
|
894
|
+
response.resolve(true);
|
|
932
895
|
}
|
|
933
896
|
|
|
934
897
|
private SQLQuery parseSQLQuery(ReadableMap params) {
|
|
@@ -951,7 +914,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
951
914
|
}
|
|
952
915
|
|
|
953
916
|
@ReactMethod
|
|
954
|
-
public void getSensors(
|
|
917
|
+
public void getSensors(Promise response) {
|
|
955
918
|
Sensors sensors = Sensors.getInstance(getReactApplicationContext());
|
|
956
919
|
WritableMap params = new WritableNativeMap();
|
|
957
920
|
params.putString("platform", "android");
|
|
@@ -959,11 +922,11 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
959
922
|
params.putBoolean("magnetometer", sensors.hasMagnetometer());
|
|
960
923
|
params.putBoolean("gyroscope", sensors.hasGyroscope());
|
|
961
924
|
params.putBoolean("significant_motion", sensors.hasSignificantMotion());
|
|
962
|
-
|
|
925
|
+
response.resolve(params);
|
|
963
926
|
}
|
|
964
927
|
|
|
965
928
|
@ReactMethod
|
|
966
|
-
public void getDeviceInfo(
|
|
929
|
+
public void getDeviceInfo(Promise response) {
|
|
967
930
|
DeviceInfo deviceInfo = DeviceInfo.getInstance(getReactApplicationContext());
|
|
968
931
|
|
|
969
932
|
WritableMap params = new WritableNativeMap();
|
|
@@ -972,72 +935,71 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
972
935
|
params.putString("version", deviceInfo.getVersion());
|
|
973
936
|
params.putString("platform", deviceInfo.getPlatform());
|
|
974
937
|
params.putString("framework", "react-native");
|
|
975
|
-
|
|
938
|
+
response.resolve(params);
|
|
976
939
|
}
|
|
977
940
|
|
|
978
941
|
@ReactMethod
|
|
979
|
-
public void isPowerSaveMode(
|
|
980
|
-
|
|
942
|
+
public void isPowerSaveMode(Promise response) {
|
|
943
|
+
response.resolve(getAdapter().isPowerSaveMode());
|
|
981
944
|
}
|
|
982
945
|
|
|
983
946
|
@ReactMethod
|
|
984
|
-
public void isIgnoringBatteryOptimizations(
|
|
947
|
+
public void isIgnoringBatteryOptimizations(Promise response) {
|
|
985
948
|
boolean isIgnoring = getAdapter().isIgnoringBatteryOptimizations();
|
|
986
|
-
|
|
949
|
+
response.resolve(isIgnoring);
|
|
987
950
|
}
|
|
988
951
|
|
|
989
952
|
@ReactMethod
|
|
990
|
-
public void requestSettings(ReadableMap args,
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
953
|
+
public void requestSettings(ReadableMap args, Promise response) {
|
|
954
|
+
try {
|
|
955
|
+
String action = args.getString("action");
|
|
956
|
+
DeviceSettingsRequest request = getAdapter().requestSettings(action);
|
|
957
|
+
if (request != null) {
|
|
958
|
+
response.resolve(mapToWritableMap(request.toMap()));
|
|
959
|
+
} else {
|
|
960
|
+
response.reject("Failed to find " + action + " screen for device " + Build.MANUFACTURER + " " + Build.MODEL + "@" + Build.VERSION.RELEASE);
|
|
961
|
+
}
|
|
962
|
+
} catch (Exception e) {
|
|
963
|
+
response.reject(e.getMessage(), e);
|
|
998
964
|
}
|
|
999
965
|
}
|
|
1000
966
|
|
|
1001
967
|
@ReactMethod
|
|
1002
|
-
public void showSettings(ReadableMap args,
|
|
968
|
+
public void showSettings(ReadableMap args, Promise response) {
|
|
1003
969
|
String action = args.getString("action");
|
|
1004
970
|
boolean didShow = getAdapter().showSettings(action);
|
|
1005
971
|
if (didShow) {
|
|
1006
|
-
|
|
972
|
+
response.resolve(true);
|
|
1007
973
|
} else {
|
|
1008
|
-
|
|
974
|
+
response.reject("Failed to find " + action + " screen for device " + Build.MANUFACTURER + " " + Build.MODEL + "@" + Build.VERSION.RELEASE);
|
|
1009
975
|
}
|
|
1010
976
|
}
|
|
1011
977
|
|
|
1012
978
|
@ReactMethod
|
|
1013
|
-
public void getProviderState(
|
|
1014
|
-
|
|
1015
|
-
success.invoke(jsonToMap(getAdapter().getProviderState().toJson()));
|
|
1016
|
-
} catch (JSONException e) {
|
|
1017
|
-
error.invoke(e.getMessage());
|
|
1018
|
-
}
|
|
979
|
+
public void getProviderState(Promise response) {
|
|
980
|
+
response.resolve(mapToWritableMap(getAdapter().getProviderState().toMap()));
|
|
1019
981
|
}
|
|
1020
982
|
|
|
1021
983
|
@ReactMethod
|
|
1022
|
-
public void requestPermission(final
|
|
984
|
+
public void requestPermission(final Promise response) {
|
|
1023
985
|
getAdapter().requestPermission(new TSRequestPermissionCallback() {
|
|
1024
986
|
@Override public void onSuccess(int status) {
|
|
1025
|
-
|
|
987
|
+
response.resolve(status);
|
|
1026
988
|
}
|
|
1027
989
|
@Override public void onFailure(int status) {
|
|
1028
|
-
|
|
990
|
+
response.reject("Permission request failed with status: " + status);
|
|
1029
991
|
}
|
|
1030
992
|
});
|
|
1031
993
|
}
|
|
1032
994
|
|
|
1033
995
|
@ReactMethod
|
|
1034
|
-
public void requestTemporaryFullAccuracy(String purpose, final
|
|
996
|
+
public void requestTemporaryFullAccuracy(String purpose, final Promise response) {
|
|
1035
997
|
getAdapter().requestTemporaryFullAccuracy(purpose, new TSRequestPermissionCallback() {
|
|
1036
998
|
@Override public void onSuccess(int accuracyAuthorization) {
|
|
1037
|
-
|
|
999
|
+
response.resolve(accuracyAuthorization);
|
|
1038
1000
|
}
|
|
1039
1001
|
@Override public void onFailure(int accuracyAuthorization) {
|
|
1040
|
-
|
|
1002
|
+
response.reject("Temporary full accuracy request failed with status: " + accuracyAuthorization);
|
|
1041
1003
|
}
|
|
1042
1004
|
});
|
|
1043
1005
|
}
|
|
@@ -1048,7 +1010,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
1048
1010
|
}
|
|
1049
1011
|
|
|
1050
1012
|
@ReactMethod
|
|
1051
|
-
public void removeListeners(
|
|
1013
|
+
public void removeListeners(double count) {
|
|
1052
1014
|
// Keep: Required for RN built-in NativeEventEmitter calls.
|
|
1053
1015
|
}
|
|
1054
1016
|
|
|
@@ -1062,7 +1024,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
1062
1024
|
private void onLocationError(Integer code) {
|
|
1063
1025
|
WritableMap params = new WritableNativeMap();
|
|
1064
1026
|
params.putInt("error", code);
|
|
1065
|
-
sendEvent(
|
|
1027
|
+
sendEvent(EventName.LOCATION, params);
|
|
1066
1028
|
}
|
|
1067
1029
|
|
|
1068
1030
|
private void handlePlayServicesConnectError(Integer errorCode) {
|
|
@@ -1074,15 +1036,95 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
1074
1036
|
}
|
|
1075
1037
|
|
|
1076
1038
|
private void sendEvent(String eventName, WritableMap params) {
|
|
1077
|
-
getReactApplicationContext()
|
|
1039
|
+
getReactApplicationContext()
|
|
1040
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
1041
|
+
.emit(eventName, params);
|
|
1078
1042
|
}
|
|
1079
1043
|
|
|
1080
1044
|
private void sendEvent(String eventName, String result) {
|
|
1081
|
-
getReactApplicationContext()
|
|
1045
|
+
getReactApplicationContext()
|
|
1046
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
1047
|
+
.emit(eventName, result);
|
|
1082
1048
|
}
|
|
1083
1049
|
|
|
1084
1050
|
private void sendEvent(String eventName, Boolean result) {
|
|
1085
|
-
getReactApplicationContext()
|
|
1051
|
+
getReactApplicationContext()
|
|
1052
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
1053
|
+
.emit(eventName, result);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
@SuppressWarnings("unchecked")
|
|
1057
|
+
public static WritableMap mapToWritableMap(Map<String, ?> src) {
|
|
1058
|
+
WritableMap map = new WritableNativeMap();
|
|
1059
|
+
if (src == null) {
|
|
1060
|
+
return map;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
for (Map.Entry<String, ?> entry : src.entrySet()) {
|
|
1064
|
+
String key = entry.getKey();
|
|
1065
|
+
Object value = entry.getValue();
|
|
1066
|
+
|
|
1067
|
+
if (value == null) {
|
|
1068
|
+
map.putNull(key);
|
|
1069
|
+
} else if (value instanceof Boolean) {
|
|
1070
|
+
map.putBoolean(key, (Boolean) value);
|
|
1071
|
+
} else if (value instanceof Integer) {
|
|
1072
|
+
map.putInt(key, (Integer) value);
|
|
1073
|
+
} else if (value instanceof Long) {
|
|
1074
|
+
map.putDouble(key, ((Long) value).doubleValue());
|
|
1075
|
+
} else if (value instanceof Float) {
|
|
1076
|
+
map.putDouble(key, ((Float) value).doubleValue());
|
|
1077
|
+
} else if (value instanceof Double) {
|
|
1078
|
+
map.putDouble(key, (Double) value);
|
|
1079
|
+
} else if (value instanceof String) {
|
|
1080
|
+
map.putString(key, (String) value);
|
|
1081
|
+
} else if (value instanceof Map) {
|
|
1082
|
+
map.putMap(key, mapToWritableMap((Map<String, ?>) value));
|
|
1083
|
+
} else if (value instanceof Iterable) {
|
|
1084
|
+
map.putArray(key, iterableToWritableArray((Iterable<Object>) value));
|
|
1085
|
+
} else if (value.getClass().isArray()) {
|
|
1086
|
+
List<Object> list = Arrays.asList((Object[]) value);
|
|
1087
|
+
map.putArray(key, iterableToWritableArray(list));
|
|
1088
|
+
} else {
|
|
1089
|
+
map.putString(key, value.toString());
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
return map;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
private static WritableArray iterableToWritableArray(Iterable<Object> src) {
|
|
1097
|
+
WritableArray array = new WritableNativeArray();
|
|
1098
|
+
if (src == null) return array;
|
|
1099
|
+
|
|
1100
|
+
for (Object value : src) {
|
|
1101
|
+
if (value == null) {
|
|
1102
|
+
array.pushNull();
|
|
1103
|
+
} else if (value instanceof Boolean) {
|
|
1104
|
+
array.pushBoolean((Boolean) value);
|
|
1105
|
+
} else if (value instanceof Integer) {
|
|
1106
|
+
array.pushInt((Integer) value);
|
|
1107
|
+
} else if (value instanceof Long) {
|
|
1108
|
+
array.pushDouble(((Long) value).doubleValue());
|
|
1109
|
+
} else if (value instanceof Float) {
|
|
1110
|
+
array.pushDouble(((Float) value).doubleValue());
|
|
1111
|
+
} else if (value instanceof Double) {
|
|
1112
|
+
array.pushDouble((Double) value);
|
|
1113
|
+
} else if (value instanceof String) {
|
|
1114
|
+
array.pushString((String) value);
|
|
1115
|
+
} else if (value instanceof Map) {
|
|
1116
|
+
array.pushMap(mapToWritableMap((Map<String, Object>) value));
|
|
1117
|
+
} else if (value instanceof Iterable) {
|
|
1118
|
+
array.pushArray(iterableToWritableArray((Iterable<Object>) value));
|
|
1119
|
+
} else if (value.getClass().isArray()) {
|
|
1120
|
+
List<Object> list = Arrays.asList((Object[]) value);
|
|
1121
|
+
array.pushArray(iterableToWritableArray(list));
|
|
1122
|
+
} else {
|
|
1123
|
+
array.pushString(value.toString());
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
return array;
|
|
1086
1128
|
}
|
|
1087
1129
|
|
|
1088
1130
|
public static WritableMap jsonToMap(JSONObject jsonObject) throws JSONException {
|
|
@@ -1227,12 +1269,7 @@ public class RNBackgroundGeolocationModule extends ReactContextBaseJavaModule im
|
|
|
1227
1269
|
}
|
|
1228
1270
|
|
|
1229
1271
|
private WritableMap getState() {
|
|
1230
|
-
|
|
1231
|
-
return jsonToMap(TSConfig.getInstance(getReactApplicationContext()).toJson());
|
|
1232
|
-
} catch (JSONException e) {
|
|
1233
|
-
e.printStackTrace();
|
|
1234
|
-
return null;
|
|
1235
|
-
}
|
|
1272
|
+
return mapToWritableMap(TSConfig.getInstance(getReactApplicationContext()).toMap(false));
|
|
1236
1273
|
}
|
|
1237
1274
|
|
|
1238
1275
|
private BackgroundGeolocation getAdapter() {
|