From efb1502d48ff10175852585af273b79b6a3fbda0 Mon Sep 17 00:00:00 2001 From: Liam Meier Date: Wed, 12 Jun 2024 12:23:59 -0400 Subject: [PATCH] Fix track verified callback (#322) * fix track verified callback * Make default interval 1200 * bump version --- .../java/io/radar/react/RNRadarModule.java | 18 +++++++++++---- ios/RNRadar.m | 22 +++++++++---------- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/android/src/main/java/io/radar/react/RNRadarModule.java b/android/src/main/java/io/radar/react/RNRadarModule.java index 08223bc6..5ab11209 100644 --- a/android/src/main/java/io/radar/react/RNRadarModule.java +++ b/android/src/main/java/io/radar/react/RNRadarModule.java @@ -97,7 +97,7 @@ public void initialize(String publishableKey, boolean fraud) { this.fraud = fraud; SharedPreferences.Editor editor = getReactApplicationContext().getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit(); editor.putString("x_platform_sdk_type", "ReactNative"); - editor.putString("x_platform_sdk_version", "3.12.0"); + editor.putString("x_platform_sdk_version", "3.12.1"); editor.apply(); if (fraud) { Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud); @@ -398,7 +398,12 @@ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarVerifie try { if (status == Radar.RadarStatus.SUCCESS) { - promise.resolve(token != null ? RNRadarUtils.mapForJson(token.toJson()) : null); + WritableMap map = Arguments.createMap(); + map.putString("status", status.toString()); + if (token != null) { + map.putMap("token", RNRadarUtils.mapForJson(token.toJson())); + } + promise.resolve(map); } else { promise.reject(status.toString(), status.toString()); } @@ -423,7 +428,12 @@ public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarVerifie try { if (status == Radar.RadarStatus.SUCCESS) { - promise.resolve(token != null ? RNRadarUtils.mapForJson(token.toJson()) : null); + WritableMap map = Arguments.createMap(); + map.putString("status", status.toString()); + if (token != null) { + map.putMap("token", RNRadarUtils.mapForJson(token.toJson())); + } + promise.resolve(map); } else { promise.reject(status.toString(), status.toString()); } @@ -466,7 +476,7 @@ public void startTrackingCustom(ReadableMap optionsMap) { @ReactMethod public void startTrackingVerified(ReadableMap optionsMap) { boolean beacons = false; - int interval = 1; + int interval = 1200; if (optionsMap != null) { beacons = optionsMap.hasKey("beacons") ? optionsMap.getBoolean("beacons") : beacons; diff --git a/ios/RNRadar.m b/ios/RNRadar.m index 2157041d..d9454ee7 100644 --- a/ios/RNRadar.m +++ b/ios/RNRadar.m @@ -137,7 +137,7 @@ - (void)didUpdateLocationPermissionStatus:(RadarLocationPermissionStatus *)statu RCT_EXPORT_METHOD(initialize:(NSString *)publishableKey fraud:(BOOL)fraud) { [[NSUserDefaults standardUserDefaults] setObject:@"ReactNative" forKey:@"radar-xPlatformSDKType"]; - [[NSUserDefaults standardUserDefaults] setObject:@"3.12.0" forKey:@"radar-xPlatformSDKVersion"]; + [[NSUserDefaults standardUserDefaults] setObject:@"3.12.1" forKey:@"radar-xPlatformSDKVersion"]; [Radar initializeWithPublishableKey:publishableKey]; } @@ -354,11 +354,12 @@ - (void)didUpdateLocationPermissionStatus:(RadarLocationPermissionStatus *)statu RadarTrackVerifiedCompletionHandler completionHandler = ^(RadarStatus status, RadarVerifiedLocationToken * _Nullable token) { if (status == RadarStatusSuccess && resolver) { + NSMutableDictionary *dict = [NSMutableDictionary new]; + [dict setObject:[Radar stringForStatus:status] forKey:@"status"]; if (token != nil) { - resolver([token dictionaryValue]); - } else { - resolver(nil); + [dict setObject:[token dictionaryValue] forKey:@"token"]; } + resolver(dict); } else if (rejecter) { rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil); } @@ -375,11 +376,12 @@ - (void)didUpdateLocationPermissionStatus:(RadarLocationPermissionStatus *)statu RadarTrackVerifiedCompletionHandler completionHandler = ^(RadarStatus status, RadarVerifiedLocationToken * _Nullable token) { if (status == RadarStatusSuccess && resolver) { + NSMutableDictionary *dict = [NSMutableDictionary new]; + [dict setObject:[Radar stringForStatus:status] forKey:@"status"]; if (token != nil) { - resolver([token dictionaryValue]); - } else { - resolver(nil); + [dict setObject:[token dictionaryValue] forKey:@"token"]; } + resolver(dict); } else if (rejecter) { rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil); } @@ -410,13 +412,9 @@ - (void)didUpdateLocationPermissionStatus:(RadarLocationPermissionStatus *)statu RCT_EXPORT_METHOD(startTrackingVerified:(NSDictionary *)optionsDict) { BOOL token = NO; BOOL beacons = NO; - double interval = 1; + double interval = 1200; if (optionsDict != nil) { - NSNumber *tokenNumber = optionsDict[@"token"]; - if (tokenNumber != nil && [tokenNumber isKindOfClass:[NSNumber class]]) { - token = [tokenNumber boolValue]; - } NSNumber *beaconsNumber = optionsDict[@"beacons"]; if (beaconsNumber != nil && [beaconsNumber isKindOfClass:[NSNumber class]]) { beacons = [beaconsNumber boolValue]; diff --git a/package-lock.json b/package-lock.json index d3614bfc..143525b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-native-radar", - "version": "3.12.0", + "version": "3.12.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "react-native-radar", - "version": "3.12.0", + "version": "3.12.1", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.21.0", diff --git a/package.json b/package.json index 71524888..97151ff2 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.12.0", + "version": "3.12.1", "main": "dist/src/index.js", "files": [ "android",