Skip to content

Commit

Permalink
Merge pull request #432 from radarlabs/is-tracking-verified-expected
Browse files Browse the repository at this point in the history
expose RadarRegion.expected, isTrackingVerified(), setProduct(), send app name/version/build
  • Loading branch information
nickpatrick authored Feb 4, 2025
2 parents 840ec42 + 6ed0873 commit ccb3f3a
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 13 deletions.
2 changes: 1 addition & 1 deletion RadarSDK.podspec
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.21.0'
s.version = '3.21.1'
s.summary = 'iOS SDK for Radar, the leading geofencing and location tracking platform'
s.homepage = 'https://radar.com'
s.author = { 'Radar Labs, Inc.' => 'support@radar.com' }
Expand Down
6 changes: 3 additions & 3 deletions RadarSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@
96A5A0BB27AD9F41007B960B /* RadarPolygonGeometry+Internal.h */,
E658DB0B2CB46B50004E0F01 /* RadarOperatingHours+Internal.h */,
DD236CAB2308812600EB88F9 /* RadarPolygonGeometry.m */,
96A5A0B527AD9F40007B960B /* RadarRegion+Internal.h */,
E658DB082CB462AA004E0F01 /* RadarOperatingHour.m */,
DD236CBC2308812700EB88F9 /* RadarRegion.m */,
96A5A0B527AD9F40007B960B /* RadarRegion+Internal.h */,
96A5A0B327AD9F40007B960B /* RadarRoute+Internal.h */,
DD4D4D1723E60E6300D36C1D /* RadarRoute.m */,
96A5A0A827AD9F40007B960B /* RadarRouteDistance+Internal.h */,
Expand Down Expand Up @@ -1062,7 +1062,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 3.21.0;
MARKETING_VERSION = 3.21.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1120,7 +1120,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 3.21.0;
MARKETING_VERSION = 3.21.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = "-fembed-bitcode";
Expand Down
27 changes: 27 additions & 0 deletions RadarSDK/Include/Radar.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,20 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
*/
+ (NSDictionary *_Nullable)getMetadata;

/**
Sets an optional product name, displayed in the dashboard and reports.
@param product A product name. If `nil`, the previous `product` will be cleared.
*/
+ (void)setProduct:(NSString *_Nullable)product;

/**
Returns the current `product`.
@return The current `product`.
*/
+ (NSString *_Nullable)getProduct;

/**
Enables anonymous tracking for privacy reasons. Avoids creating user records on the server and avoids sending any stable device IDs, user IDs, and user metadata
to the server when calling `trackOnce()` or `startTracking()`. Disabled by default.
Expand Down Expand Up @@ -503,14 +517,27 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status
@param beacons A boolean indicating whether to range beacons.
@warning Note that you must configure SSL pinning before calling this method.
@see https://radar.com/documentation/fraud
*/
+ (void)startTrackingVerifiedWithInterval:(NSTimeInterval)interval beacons:(BOOL)beacons NS_SWIFT_NAME(startTrackingVerified(interval:beacons:));

/**
Stops tracking the user's location with device integrity information for location verification use cases.
@see https://radar.com/documentation/fraud
*/
+ (void)stopTrackingVerified NS_SWIFT_NAME(stopTrackingVerified());

/**
Returns a boolean indicating whether verified tracking has been started.
@return A boolean indicating whether verified tracking has been started.
@see https://radar.com/documentation/sdk/fraud
*/
+ (BOOL)isTrackingVerified;

/**
Returns the user's last verified location token if still valid, or requests a fresh token if not.
Expand Down
5 changes: 5 additions & 0 deletions RadarSDK/Include/RadarRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (assign, nonatomic, readonly) double distanceToBorder;

/**
A boolean indicating whether the jurisdiction is expected based on the values passed to `setExpectedJurisdiction()`.
*/
@property (assign, nonatomic, readonly) BOOL expected;

/**
*/
Expand Down
12 changes: 12 additions & 0 deletions RadarSDK/Radar.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ + (NSDictionary *_Nullable)getMetadata {
return [RadarSettings metadata];
}

+ (void)setProduct:(NSString *)product {
[RadarSettings setProduct:product];
}

+ (NSString *_Nullable)getProduct {
return [RadarSettings product];
}

+ (void)setAnonymousTrackingEnabled:(BOOL)enabled {
[RadarSettings setAnonymousTrackingEnabled:enabled];
}
Expand Down Expand Up @@ -309,6 +317,10 @@ + (void)stopTrackingVerified {
[[RadarVerificationManager sharedInstance] stopTrackingVerified];
}

+ (BOOL)isTrackingVerified {
return [RadarVerificationManager sharedInstance].started;
}

+ (void)getVerifiedLocationToken:(RadarTrackVerifiedCompletionHandler)completionHandler {
[self getVerifiedLocationTokenWithBeacons:NO desiredAccuracy:RadarTrackingOptionsDesiredAccuracyMedium completionHandler:completionHandler];
}
Expand Down
15 changes: 14 additions & 1 deletion RadarSDK/RadarAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location
params[@"sessionId"] = sessionId;
}
}
params[@"product"] = [RadarSettings product];
params[@"latitude"] = @(location.coordinate.latitude);
params[@"longitude"] = @(location.coordinate.longitude);
CLLocationAccuracy accuracy = location.horizontalAccuracy;
Expand Down Expand Up @@ -342,7 +343,19 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location
}
}
params[@"appId"] = [[NSBundle mainBundle] bundleIdentifier];
if (sdkConfiguration.useLocationMetadata) {
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
if (appName) {
params[@"appName"] = appName;
}
NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
if (appVersion) {
params[@"appVersion"] = appVersion;
}
NSString *appBuild = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
if (appBuild) {
params[@"appBuild"] = appBuild;
}
if (sdkConfiguration.useLocationMetadata) {
NSMutableDictionary *locationMetadata = [NSMutableDictionary new];
locationMetadata[@"motionActivityData"] = [RadarState lastMotionActivityData];
locationMetadata[@"heading"] = [RadarState lastHeadingData];
Expand Down
3 changes: 2 additions & 1 deletion RadarSDK/RadarRegion+Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
passed:(BOOL)passed
inExclusionZone:(BOOL)inExclusionZone
inBufferZone:(BOOL)inBufferZone
distanceToBorder:(double)distanceToBorder;
distanceToBorder:(double)distanceToBorder
expected:(BOOL)expected;
- (nullable instancetype)initWithObject:(nullable id)object;

@end
15 changes: 13 additions & 2 deletions RadarSDK/RadarRegion.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ - (instancetype)initWithId:(nonnull NSString *)_id
passed:(BOOL)passed
inExclusionZone:(BOOL)inExclusionZone
inBufferZone:(BOOL)inBufferZone
distanceToBorder:(double)distanceToBorder {
distanceToBorder:(double)distanceToBorder
expected:(BOOL)expected{
self = [super init];
if (self) {
__id = _id;
Expand All @@ -31,6 +32,7 @@ - (instancetype)initWithId:(nonnull NSString *)_id
_inExclusionZone = inExclusionZone;
_inBufferZone = inBufferZone;
_distanceToBorder = distanceToBorder;
_expected = expected;
}
return self;
}
Expand All @@ -52,6 +54,7 @@ - (nullable instancetype)initWithObject:(nullable id)object {
BOOL inExclusionZone = false;
BOOL inBufferZone = false;
double distanceToBorder = 0;
BOOL expected = false;

id idObj = dict[@"_id"];
if ([idObj isKindOfClass:[NSString class]]) {
Expand Down Expand Up @@ -110,9 +113,16 @@ - (nullable instancetype)initWithObject:(nullable id)object {
if ([distanceToBorderObj isKindOfClass:[NSNumber class]]) {
distanceToBorder = ((NSNumber *)distanceToBorderObj).doubleValue;
}

id expectedObj = dict[@"expected"];
if (expectedObj && [expectedObj isKindOfClass:[NSNumber class]]) {
NSNumber *expectedNumber = (NSNumber *)expectedObj;

expected = [expectedNumber boolValue];
}

if (_id && name && code && type) {
return [[RadarRegion alloc] initWithId:_id name:name code:code type:type flag:flag allowed:allowed passed:passed inExclusionZone:inExclusionZone inBufferZone:inBufferZone distanceToBorder:distanceToBorder];
return [[RadarRegion alloc] initWithId:_id name:name code:code type:type flag:flag allowed:allowed passed:passed inExclusionZone:inExclusionZone inBufferZone:inBufferZone distanceToBorder:distanceToBorder expected:expected];
}

return nil;
Expand All @@ -132,6 +142,7 @@ - (NSDictionary *)dictionaryValue {
[dict setValue:@(self.inExclusionZone) forKey:@"inExclusionZone"];
[dict setValue:@(self.inBufferZone) forKey:@"inBufferZone"];
[dict setValue:@(self.distanceToBorder) forKey:@"distanceToBorder"];
[dict setValue:@(self.expected) forKey:@"expected"];
return dict;
}

Expand Down
2 changes: 2 additions & 0 deletions RadarSDK/RadarSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)setUserId:(NSString *_Nullable)userId;
+ (NSString *_Nullable)__description;
+ (void)setDescription:(NSString *_Nullable)description;
+ (NSString *_Nullable)product;
+ (void)setProduct:(NSString *_Nullable)product;
+ (NSDictionary *_Nullable)metadata;
+ (void)setMetadata:(NSDictionary *_Nullable)metadata;
+ (BOOL)anonymousTrackingEnabled;
Expand Down
9 changes: 9 additions & 0 deletions RadarSDK/RadarSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ @implementation RadarSettings
static NSString *const kId = @"radar-_id";
static NSString *const kUserId = @"radar-userId";
static NSString *const kDescription = @"radar-description";
static NSString *const kProduct = @"radar-product";
static NSString *const kMetadata = @"radar-metadata";
static NSString *const kAnonymous = @"radar-anonymous";
static NSString *const kTracking = @"radar-tracking";
Expand Down Expand Up @@ -120,6 +121,14 @@ + (void)setDescription:(NSString *)description {
[[NSUserDefaults standardUserDefaults] setObject:description forKey:kDescription];
}

+ (NSString *)product {
return [[NSUserDefaults standardUserDefaults] stringForKey:kProduct];
}

+ (void)setProduct:(NSString *)product {
[[NSUserDefaults standardUserDefaults] setObject:product forKey:kProduct];
}

+ (NSDictionary *)metadata {
return [[NSUserDefaults standardUserDefaults] dictionaryForKey:kMetadata];
}
Expand Down
2 changes: 1 addition & 1 deletion RadarSDK/RadarUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ + (NSNumber *)timeZoneOffset {
}

+ (NSString *)sdkVersion {
return @"3.21.0";
return @"3.21.1";
}

+ (NSString *)deviceId {
Expand Down
2 changes: 2 additions & 0 deletions RadarSDK/RadarVerificationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface RadarVerificationManager : NSObject

@property (assign, nonatomic) BOOL started;

typedef void (^_Nullable RadarVerificationCompletionHandler)(NSString *_Nullable attestationString, NSString *_Nullable keyId, NSString *_Nullable attestationError);

+ (instancetype)sharedInstance;
Expand Down
1 change: 0 additions & 1 deletion RadarSDK/RadarVerificationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

@interface RadarVerificationManager ()

@property (assign, nonatomic) BOOL started;
@property (assign, nonatomic) NSTimeInterval startedInterval;
@property (assign, nonatomic) BOOL startedBeacons;
@property (strong, nonatomic) NSTimer *intervalTimer;
Expand Down
2 changes: 1 addition & 1 deletion RadarSDKMotion.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RadarSDKMotion'
s.version = '3.21.0'
s.version = '3.21.1'
s.summary = 'Motion detection plugin for RadarSDK, the leading geofencing and location tracking platform'
s.homepage = 'https://radar.com'
s.author = { 'Radar Labs, Inc.' => 'support@radar.com' }
Expand Down
4 changes: 2 additions & 2 deletions RadarSDKMotion/RadarSDKMotion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 3.21.0;
MARKETING_VERSION = 3.21.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -348,7 +348,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 3.21.0;
MARKETING_VERSION = 3.21.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down

0 comments on commit ccb3f3a

Please sign in to comment.