-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add trackVerifiedToken() #270
Changes from all commits
eb135b1
be700de
15258c6
4753a69
085453f
6ce4f43
4fd1f21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Pod::Spec.new do |s| | ||
s.name = 'RadarSDK' | ||
s.version = '3.8.4' | ||
s.version = '3.8.5' | ||
s.summary = 'iOS SDK for Radar, the leading geofencing and location tracking platform' | ||
s.homepage = 'https://radar.com' | ||
s.author = { 'Radar Labs, Inc.' => '[email protected]' } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,7 @@ + (void)trackOnceWithDesiredAccuracy:(RadarTrackingOptionsDesiredAccuracy)desire | |
replayed:NO | ||
beacons:beacons | ||
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarEvent *> *_Nullable events, RadarUser *_Nullable user, | ||
NSArray<RadarGeofence *> *_Nullable nearbyGeofences, RadarConfig *_Nullable config) { | ||
NSArray<RadarGeofence *> *_Nullable nearbyGeofences, RadarConfig *_Nullable config, NSString *_Nullable token) { | ||
if (status == RadarStatusSuccess) { | ||
[[RadarLocationManager sharedInstance] replaceSyncedGeofences:nearbyGeofences]; | ||
} | ||
|
@@ -219,7 +219,7 @@ + (void)trackOnceWithLocation:(CLLocation *)location completionHandler:(RadarTra | |
replayed:NO | ||
beacons:nil | ||
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarEvent *> *_Nullable events, RadarUser *_Nullable user, | ||
NSArray<RadarGeofence *> *_Nullable nearbyGeofences, RadarConfig *_Nullable config) { | ||
NSArray<RadarGeofence *> *_Nullable nearbyGeofences, RadarConfig *_Nullable config, NSString *_Nullable token) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we call out anywhere that the rest of the objects in this callback will be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This callback is only ever used internally, not worried about it |
||
|
||
if (completionHandler) { | ||
[RadarUtils runOnMainThread:^{ | ||
|
@@ -260,9 +260,10 @@ + (void)trackVerifiedWithCompletionHandler:(RadarTrackCompletionHandler)completi | |
attestationString:attestationString | ||
keyId:keyId | ||
attestationError:attestationError | ||
encrypted:YES | ||
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarEvent *> *_Nullable events, | ||
RadarUser *_Nullable user, NSArray<RadarGeofence *> *_Nullable nearbyGeofences, | ||
RadarConfig *_Nullable config) { | ||
RadarConfig *_Nullable config, NSString *_Nullable token) { | ||
if (completionHandler) { | ||
[RadarUtils runOnMainThread:^{ | ||
completionHandler(status, location, events, user); | ||
|
@@ -274,6 +275,52 @@ + (void)trackVerifiedWithCompletionHandler:(RadarTrackCompletionHandler)completi | |
}]; | ||
} | ||
|
||
+ (void)trackVerifiedTokenWithCompletionHandler:(RadarTrackTokenCompletionHandler)completionHandler { | ||
[[RadarAPIClient sharedInstance] | ||
getConfigForUsage:@"verify" verified:YES | ||
completionHandler:^(RadarStatus status, RadarConfig *_Nullable config) { | ||
[[RadarLocationManager sharedInstance] | ||
getLocationWithDesiredAccuracy:RadarTrackingOptionsDesiredAccuracyHigh | ||
completionHandler:^(RadarStatus status, CLLocation *_Nullable location, BOOL stopped) { | ||
if (status != RadarStatusSuccess) { | ||
if (completionHandler) { | ||
[RadarUtils runOnMainThread:^{ | ||
completionHandler(status, nil); | ||
}]; | ||
} | ||
|
||
return; | ||
} | ||
|
||
[[RadarVerificationManager sharedInstance] | ||
getAttestationWithNonce:config.nonce | ||
completionHandler:^(NSString *_Nullable attestationString, NSString *_Nullable keyId, NSString *_Nullable attestationError) { | ||
[[RadarAPIClient sharedInstance] | ||
trackWithLocation:location | ||
stopped:RadarState.stopped | ||
foreground:[RadarUtils foreground] | ||
source:RadarLocationSourceForegroundLocation | ||
replayed:NO | ||
beacons:nil | ||
verified:YES | ||
attestationString:attestationString | ||
keyId:keyId | ||
attestationError:attestationError | ||
encrypted:YES | ||
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarEvent *> *_Nullable events, | ||
RadarUser *_Nullable user, NSArray<RadarGeofence *> *_Nullable nearbyGeofences, | ||
RadarConfig *_Nullable config, NSString *_Nullable token) { | ||
if (completionHandler) { | ||
[RadarUtils runOnMainThread:^{ | ||
completionHandler(status, token); | ||
}]; | ||
} | ||
}]; | ||
}]; | ||
}]; | ||
}]; | ||
} | ||
|
||
+ (void)startTrackingWithOptions:(RadarTrackingOptions *)options { | ||
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeSDKCall message:@"startTracking()"]; | ||
[[RadarLocationManager sharedInstance] startTrackingWithOptions:options]; | ||
|
@@ -345,7 +392,7 @@ + (void)mockTrackingWithOrigin:(CLLocation *)origin | |
replayed:NO | ||
beacons:nil | ||
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarEvent *> *_Nullable events, RadarUser *_Nullable user, | ||
NSArray<RadarGeofence *> *_Nullable nearbyGeofences, RadarConfig *_Nullable config) { | ||
NSArray<RadarGeofence *> *_Nullable nearbyGeofences, RadarConfig *_Nullable config, NSString *_Nullable token) { | ||
if (completionHandler) { | ||
[RadarUtils runOnMainThread:^{ | ||
completionHandler(status, location, events, user); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,8 @@ typedef void (^_Nonnull RadarTrackAPICompletionHandler)(RadarStatus status, | |
NSArray<RadarEvent *> *_Nullable events, | ||
RadarUser *_Nullable user, | ||
NSArray<RadarGeofence *> *_Nullable nearbyGeofences, | ||
RadarConfig *_Nullable config); | ||
RadarConfig *_Nullable config, | ||
NSString *_Nullable token); | ||
|
||
typedef void (^_Nonnull RadarTripAPICompletionHandler)(RadarStatus status, RadarTrip *_Nullable trip, NSArray<RadarEvent *> *_Nullable events); | ||
|
||
|
@@ -86,6 +87,7 @@ typedef void (^_Nonnull RadarSyncLogsAPICompletionHandler)(RadarStatus status); | |
attestationString:(NSString *_Nullable)attestationString | ||
keyId:(NSString *_Nullable)keyId | ||
attestationError:(NSString *_Nullable)attestationError | ||
encrypted:(BOOL)encrypted | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was going to suggest we think about changing this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the JWT docs, I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking we can change param or endpoint name or switch to a project setting later on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
completionHandler:(RadarTrackAPICompletionHandler _Nonnull)completionHandler; | ||
|
||
- (void)verifyEventId:(NSString *_Nonnull)eventId verification:(RadarEventVerification)verification verifiedPlaceId:(NSString *_Nullable)verifiedPlaceId; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,7 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location | |
attestationString:nil | ||
keyId:nil | ||
attestationError:nil | ||
encrypted:NO | ||
completionHandler:completionHandler]; | ||
} | ||
|
||
|
@@ -143,10 +144,11 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location | |
attestationString:(NSString *_Nullable)attestationString | ||
keyId:(NSString *_Nullable)keyId | ||
attestationError:(NSString *_Nullable)attestationError | ||
encrypted:(BOOL)encrypted | ||
completionHandler:(RadarTrackAPICompletionHandler _Nonnull)completionHandler { | ||
NSString *publishableKey = [RadarSettings publishableKey]; | ||
if (!publishableKey) { | ||
return completionHandler(RadarStatusErrorPublishableKey, nil, nil, nil, nil, nil); | ||
return completionHandler(RadarStatusErrorPublishableKey, nil, nil, nil, nil, nil, nil); | ||
} | ||
NSMutableDictionary *params = [NSMutableDictionary new]; | ||
BOOL anonymous = [RadarSettings anonymousTrackingEnabled]; | ||
|
@@ -257,6 +259,7 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location | |
params[@"attestationString"] = attestationString; | ||
params[@"keyId"] = keyId; | ||
params[@"attestationError"] = attestationError; | ||
params[@"encrypted"] = @(encrypted); | ||
} | ||
params[@"appId"] = [[NSBundle mainBundle] bundleIdentifier]; | ||
|
||
|
@@ -314,7 +317,7 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location | |
|
||
[[RadarDelegateHolder sharedInstance] didFailWithStatus:status]; | ||
|
||
return completionHandler(status, nil, nil, nil, nil, nil); | ||
return completionHandler(status, nil, nil, nil, nil, nil, nil); | ||
} | ||
|
||
[[RadarReplayBuffer sharedInstance] clearBuffer]; | ||
|
@@ -327,10 +330,21 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location | |
id eventsObj = res[@"events"]; | ||
id userObj = res[@"user"]; | ||
id nearbyGeofencesObj = res[@"nearbyGeofences"]; | ||
id tokenObj = res[@"token"]; | ||
NSArray<RadarEvent *> *events = [RadarEvent eventsFromObject:eventsObj]; | ||
RadarUser *user = [[RadarUser alloc] initWithObject:userObj]; | ||
NSArray<RadarGeofence *> *nearbyGeofences = [RadarGeofence geofencesFromObject:nearbyGeofencesObj]; | ||
|
||
if (encrypted) { | ||
if (!tokenObj) { | ||
return completionHandler(status, nil, nil, nil, nil, nil, nil); | ||
} | ||
|
||
NSString *token = (NSString *)tokenObj; | ||
|
||
return completionHandler(status, nil, nil, nil, nil, nil, token); | ||
} | ||
Comment on lines
+338
to
+346
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This codepath is completely forgoing updating the event & location update handlers, trips, & place updating. As such, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will mention on |
||
|
||
if (user) { | ||
BOOL inGeofences = user.geofences && user.geofences.count; | ||
BOOL atPlace = user.place != nil; | ||
|
@@ -394,12 +408,12 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location | |
[[RadarDelegateHolder sharedInstance] didReceiveEvents:events user:user]; | ||
} | ||
|
||
return completionHandler(RadarStatusSuccess, res, events, user, nearbyGeofences, config); | ||
return completionHandler(RadarStatusSuccess, res, events, user, nearbyGeofences, config, nil); | ||
} | ||
|
||
[[RadarDelegateHolder sharedInstance] didFailWithStatus:status]; | ||
|
||
completionHandler(RadarStatusErrorServer, nil, nil, nil, nil, nil); | ||
completionHandler(RadarStatusErrorServer, nil, nil, nil, nil, nil, nil); | ||
}]; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a use case where a customer would want the payload encrypted through the vanilla
trackOnce
call and not necessarily need SSL pinning? wondering if we should add anencrypted
option here tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is, I think if they want the encrypted payload they have to do the full
trackVerified
experience.