Skip to content

Commit

Permalink
expose trackVerifiedToken() (#252)
Browse files Browse the repository at this point in the history
* expose trackVerifiedToken(), bump versions

* npm i

* update example app

* bump version
  • Loading branch information
nickpatrick authored Aug 22, 2023
1 parent 4bbb10c commit 7191cac
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 12 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName '3.8.6'
versionName '3.8.7'
}
lintOptions {
abortOnError false
Expand All @@ -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'
}
28 changes: 28 additions & 0 deletions android/src/main/java/io/radar/react/RNRadarModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,19 @@ export default function App() {
});
}}
/>

<ExampleButton
title="trackVerifiedToken"
onPress={() => {
Radar.trackVerifiedToken()
.then((result) => {
handlePopulateText("trackVerifiedToken:" + stringify(result));
})
.catch((err) => {
handlePopulateText("trackVerifiedToken:" + err);
});
}}
/>
</ScrollView>
</View>
</View>
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ios/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "radarlabs/radar-sdk-ios" "3.8.4"
github "radarlabs/radar-sdk-ios" "3.8.5"
21 changes: 21 additions & 0 deletions ios/RNRadar.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 5 additions & 0 deletions js/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ const trackVerified = () => (
NativeModules.RNRadar.trackVerified()
);

const trackVerifiedToken = () => (
NativeModules.RNRadar.trackVerifiedToken()
);

const startTrackingEfficient = () => (
NativeModules.RNRadar.startTrackingEfficient()
);
Expand Down Expand Up @@ -205,6 +209,7 @@ const Radar = {
getLocation,
trackOnce,
trackVerified,
trackVerifiedToken,
startTrackingEfficient,
startTrackingResponsive,
startTrackingContinuous,
Expand Down
5 changes: 5 additions & 0 deletions js/index.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ const trackVerified = () => {
// not implemented
};

const trackVerifiedToken = () => {
// not implemented
};

const startTrackingEfficient = () => {
// not implemented
};
Expand Down Expand Up @@ -376,6 +380,7 @@ const Radar = {
getLocation,
trackOnce,
trackVerified,
trackVerifiedToken,
startTrackingEfficient,
startTrackingResponsive,
startTrackingContinuous,
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.8.5",
"version": "3.8.7",
"main": "js/index.js",
"files": [
"android",
Expand Down
2 changes: 1 addition & 1 deletion react-native-radar.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7191cac

Please sign in to comment.