Skip to content

Commit

Permalink
Fix track verified callback (#322)
Browse files Browse the repository at this point in the history
* fix track verified callback

* Make default interval 1200

* bump version
  • Loading branch information
lmeier authored Jun 12, 2024
1 parent 72cb410 commit efb1502
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
18 changes: 14 additions & 4 deletions android/src/main/java/io/radar/react/RNRadarModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 10 additions & 12 deletions ios/RNRadar.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit efb1502

Please sign in to comment.