From 7191cac0deb57a204f89cbcb0c898e335dbb2307 Mon Sep 17 00:00:00 2001 From: Nick Patrick Date: Tue, 22 Aug 2023 07:29:36 -0400 Subject: [PATCH] expose trackVerifiedToken() (#252) * expose trackVerifiedToken(), bump versions * npm i * update example app * bump version --- android/build.gradle | 4 +-- .../java/io/radar/react/RNRadarModule.java | 28 +++++++++++++++++++ example/App.js | 13 +++++++++ example/ios/Podfile.lock | 10 +++---- ios/Cartfile.resolved | 2 +- ios/RNRadar.m | 21 ++++++++++++++ js/index.native.js | 5 ++++ js/index.web.js | 5 ++++ package-lock.json | 4 +-- package.json | 2 +- react-native-radar.podspec | 2 +- 11 files changed, 84 insertions(+), 12 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 469bdcfa..24773dca 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -18,7 +18,7 @@ android { minSdkVersion 16 targetSdkVersion 31 versionCode 1 - versionName '3.8.6' + versionName '3.8.7' } lintOptions { abortOnError false @@ -45,5 +45,5 @@ repositories { dependencies { api 'com.facebook.react:react-native:+' - api 'io.radar:sdk:3.8.6' + api 'io.radar:sdk:3.8.7' } diff --git a/android/src/main/java/io/radar/react/RNRadarModule.java b/android/src/main/java/io/radar/react/RNRadarModule.java index 1c7d9f8a..ea7e630e 100644 --- a/android/src/main/java/io/radar/react/RNRadarModule.java +++ b/android/src/main/java/io/radar/react/RNRadarModule.java @@ -377,6 +377,34 @@ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location loc }); } + @ReactMethod + public void trackVerifiedToken(final Promise promise) { + Radar.trackVerifiedToken(new Radar.RadarTrackTokenCallback() { + @Override + public void onComplete(@NonNull Radar.RadarStatus status, @Nullable String token) { + if (promise == null) { + return; + } + + try { + if (status == Radar.RadarStatus.SUCCESS) { + WritableMap map = Arguments.createMap(); + map.putString("status", status.toString()); + if (token != null) { + map.putString("token", token); + } + promise.resolve(map); + } else { + promise.reject(status.toString(), status.toString()); + } + } catch (Exception e) { + Log.e(TAG, "Exception", e); + promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString()); + } + } + }); + } + @ReactMethod public void startTrackingEfficient() { Radar.startTracking(RadarTrackingOptions.EFFICIENT); diff --git a/example/App.js b/example/App.js index 8d758c5a..745e0950 100644 --- a/example/App.js +++ b/example/App.js @@ -492,6 +492,19 @@ export default function App() { }); }} /> + + { + Radar.trackVerifiedToken() + .then((result) => { + handlePopulateText("trackVerifiedToken:" + stringify(result)); + }) + .catch((err) => { + handlePopulateText("trackVerifiedToken:" + err); + }); + }} + /> diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 3c7facd2..332afe09 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -48,7 +48,7 @@ PODS: - maplibre-react-native/DynamicLibrary (9.0.1): - React - React-Core - - RadarSDK (3.8.4) + - RadarSDK (3.8.5) - RCT-Folly (2020.01.13.00): - boost-for-react-native - DoubleConversion @@ -242,8 +242,8 @@ PODS: - React-jsi (= 0.64.3) - React-perflogger (= 0.64.3) - React-jsinspector (0.64.3) - - react-native-radar (3.8.5): - - RadarSDK (~> 3.8.4) + - react-native-radar (3.8.7): + - RadarSDK (~> 3.8.5) - React - react-native-safe-area-context (3.3.2): - React-Core @@ -532,7 +532,7 @@ SPEC CHECKSUMS: FBReactNativeSpec: 0927ccb6f474e439386ebce65cccb07b9612e950 glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 maplibre-react-native: f08cc1b867c4b3080b34955f8e2ce938361df4c2 - RadarSDK: 00aac8132174517cd0de9b43af0aa168edaf5a4c + RadarSDK: 7e5e130540c796cfc0a326bbe10b8992d852f2e1 RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c RCTRequired: d34bf57e17cb6e3b2681f4809b13843c021feb6c RCTTypeSafety: 8dab4933124ed39bb0c1d88d74d61b1eb950f28f @@ -544,7 +544,7 @@ SPEC CHECKSUMS: React-jsi: a8b09c29521c798f1783348b37b511ba7b3dbeb3 React-jsiexecutor: df6abc9fafbecb8e5b7a5fbc5e6d4bd017d594d5 React-jsinspector: 34e23860273a23695342f58eed3ffd3ba10c31e0 - react-native-radar: 387abf87eb20ad528ee5bd5cd81fa57e8a230475 + react-native-radar: 02f813320fc911110f1d056d3a1688784ce4ec9d react-native-safe-area-context: 584dc04881deb49474363f3be89e4ca0e854c057 React-perflogger: cc76a4254d19640f1d8ad1c66fdee800414b805c React-RCTActionSheet: 7448f049318d8d7e8a9a1ebb742ada721757eea8 diff --git a/ios/Cartfile.resolved b/ios/Cartfile.resolved index 3cc29a62..8cc9c38e 100644 --- a/ios/Cartfile.resolved +++ b/ios/Cartfile.resolved @@ -1 +1 @@ -github "radarlabs/radar-sdk-ios" "3.8.4" +github "radarlabs/radar-sdk-ios" "3.8.5" diff --git a/ios/RNRadar.m b/ios/RNRadar.m index 3d3b439c..aa25a243 100644 --- a/ios/RNRadar.m +++ b/ios/RNRadar.m @@ -319,6 +319,27 @@ - (void)didLogMessage:(NSString *)message { [Radar trackVerifiedWithCompletionHandler:completionHandler]; } +RCT_EXPORT_METHOD(trackVerifiedToken:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { + __block RCTPromiseResolveBlock resolver = resolve; + __block RCTPromiseRejectBlock rejecter = reject; + + RadarTrackTokenCompletionHandler completionHandler = ^(RadarStatus status, NSString * _Nullable token) { + if (status == RadarStatusSuccess && resolver) { + NSMutableDictionary *dict = [NSMutableDictionary new]; + [dict setObject:[Radar stringForStatus:status] forKey:@"status"]; + if (token) { + [dict setObject:token forKey:@"token"]; + } + resolver(dict); + } else if (rejecter) { + rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil); + } + resolver = nil; + rejecter = nil; + }; + + [Radar trackVerifiedTokenWithCompletionHandler:completionHandler]; +} RCT_EXPORT_METHOD(startTrackingEfficient) { [Radar startTrackingWithOptions:RadarTrackingOptions.presetEfficient]; diff --git a/js/index.native.js b/js/index.native.js index a97b8e4a..16fddf8d 100644 --- a/js/index.native.js +++ b/js/index.native.js @@ -70,6 +70,10 @@ const trackVerified = () => ( NativeModules.RNRadar.trackVerified() ); +const trackVerifiedToken = () => ( + NativeModules.RNRadar.trackVerifiedToken() +); + const startTrackingEfficient = () => ( NativeModules.RNRadar.startTrackingEfficient() ); @@ -205,6 +209,7 @@ const Radar = { getLocation, trackOnce, trackVerified, + trackVerifiedToken, startTrackingEfficient, startTrackingResponsive, startTrackingContinuous, diff --git a/js/index.web.js b/js/index.web.js index 3b7c4242..632886d4 100644 --- a/js/index.web.js +++ b/js/index.web.js @@ -91,6 +91,10 @@ const trackVerified = () => { // not implemented }; +const trackVerifiedToken = () => { + // not implemented +}; + const startTrackingEfficient = () => { // not implemented }; @@ -376,6 +380,7 @@ const Radar = { getLocation, trackOnce, trackVerified, + trackVerifiedToken, startTrackingEfficient, startTrackingResponsive, startTrackingContinuous, diff --git a/package-lock.json b/package-lock.json index 753a69e4..c14baaf1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-native-radar", - "version": "3.8.5", + "version": "3.8.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "react-native-radar", - "version": "3.8.5", + "version": "3.8.7", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.21.0", diff --git a/package.json b/package.json index ce96e017..19ca1fc9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "React Native module for Radar, the leading geofencing and location tracking platform", "homepage": "https://radar.com", "license": "Apache-2.0", - "version": "3.8.5", + "version": "3.8.7", "main": "js/index.js", "files": [ "android", diff --git a/react-native-radar.podspec b/react-native-radar.podspec index a658229c..88f53355 100644 --- a/react-native-radar.podspec +++ b/react-native-radar.podspec @@ -15,5 +15,5 @@ Pod::Spec.new do |s| s.platform = :ios, "10.0" s.dependency "React" - s.dependency "RadarSDK", "~> 3.8.4" + s.dependency "RadarSDK", "~> 3.8.5" end