Skip to content

Commit

Permalink
Merge branch 'master' into start-tracking-verified-2
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpatrick authored Jan 19, 2024
2 parents df64e4d + 3211df7 commit 0bcaa6e
Show file tree
Hide file tree
Showing 28 changed files with 631 additions and 73 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/release-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@ jobs:
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

- name: Build archive for iPhone simulator
run: xcodebuild archive -scheme RadarSDK -archivePath "RadarSDK-iphonesimulator.xcarchive" -sdk iphonesimulator SKIP_INSTALL=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO

- name: Build archive for iPhone device
run: xcodebuild archive -scheme RadarSDK -archivePath "RadarSDK-iphoneos.xcarchive" -sdk iphoneos SKIP_INSTALL=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO

- name: Build XCFramework
run: xcodebuild -create-xcframework -framework RadarSDK-iphonesimulator.xcarchive/Products/Library/Frameworks/RadarSDK.framework -framework RadarSDK-iphoneos.xcarchive/Products/Library/Frameworks/RadarSDK.framework -output RadarSDK.xcframework

- name: Zip XCFramework
run: zip -r RadarSDK.xcframework.zip RadarSDK.xcframework -x ".*" -x "__MACOSX" -D

- name: Upload XCFramework to release
uses: svenstaro/upload-release-action@v2
with:
file: RadarSDK.xcframework.zip
18 changes: 17 additions & 1 deletion Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
let origin = CLLocation(latitude: 40.78382, longitude: -73.97536)
let destination = CLLocation(latitude: 40.70390, longitude: -73.98670)

Radar.autocomplete(
query: "brooklyn",
near: origin,
layers: ["locality"],
limit: 10,
country: "US",
expandUnits: true
) { (status, addresses) in
print("Autocomplete: status = \(Radar.stringForStatus(status)); formattedAddress = \(String(describing: addresses?.first?.formattedAddress))")

if let address = addresses?.first {
Radar.validateAddress(address: address) { (status, address, verificationStatus) in
print("Validate address: status = \(Radar.stringForStatus(status)); address = \(String(describing: address)); verificationStatus = \(Radar.stringForVerificationStatus(verificationStatus))")
}
}
}

Radar.autocomplete(
query: "brooklyn",
near: origin,
layers: ["locality"],
limit: 10,
country: "US",
expandUnits:true
mailable:true
) { (status, addresses) in
print("Autocomplete: status = \(Radar.stringForStatus(status)); formattedAddress = \(String(describing: addresses?.first?.formattedAddress))")

Expand Down
4 changes: 4 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Migration guides

## 3.8.x to 3.9.0
- The `Radar.autocomplete(query:near:layers:limit:country:expandUnits:completionHandler:)` method is now `Radar.autocomplete(query:near:layers:limit:country:mailable:completionHandler:)`.
- `expandUnits` has been deprecated and will always be true regardless of value passed in.

## 3.6.x to 3.7.0
- Custom events have been renamed to conversions.
- `Radar.sendEvent(customType:metadata:completionHandler:)` is now `Radar.logConversion(name:metadata:completionHandler)`.
Expand Down
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.8.10-beta.1'
s.version = '3.9.2-beta.1'
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]' }
Expand Down
16 changes: 12 additions & 4 deletions RadarSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
DD8E2F7A24018C37002D51AB /* CLLocationManagerMock.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8E2F7924018C37002D51AB /* CLLocationManagerMock.m */; };
DD8E2F7D24018C54002D51AB /* CLVisitMock.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8E2F7C24018C54002D51AB /* CLVisitMock.m */; };
DE1E7644239724FD006F34A1 /* search_geofences.json in Resources */ = {isa = PBXBuildFile; fileRef = DE1E7643239724FD006F34A1 /* search_geofences.json */; };
E6EEC56E2B20F41A00DD096B /* RadarFileStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E6EEC56D2B20F41A00DD096B /* RadarFileStorage.h */; };
E6EEC5702B20F45D00DD096B /* RadarFileStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = E6EEC56F2B20F45D00DD096B /* RadarFileStorage.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -318,6 +320,8 @@
DDD7BD0325EC3015002473B3 /* RadarRouteMatrix.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RadarRouteMatrix.m; sourceTree = "<group>"; };
DDF1157C2524E18100D575C4 /* RadarTrip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RadarTrip.m; sourceTree = "<group>"; };
DE1E7643239724FD006F34A1 /* search_geofences.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = search_geofences.json; sourceTree = "<group>"; };
E6EEC56D2B20F41A00DD096B /* RadarFileStorage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RadarFileStorage.h; sourceTree = "<group>"; };
E6EEC56F2B20F45D00DD096B /* RadarFileStorage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RadarFileStorage.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -447,6 +451,8 @@
58F950CF2407038300364B15 /* RadarCollectionAdditions.m */,
01F99CFA2965C182004E8CF3 /* RadarConfig.h */,
01F99CFC2965C1C4004E8CF3 /* RadarConfig.m */,
E6EEC56D2B20F41A00DD096B /* RadarFileStorage.h */,
E6EEC56F2B20F45D00DD096B /* RadarFileStorage.m */,
96A5A11727ADA02E007B960B /* RadarDelegateHolder.h */,
DD4C104925D87E3E009C2E36 /* RadarDelegateHolder.m */,
82EEA9292A9E684C0048DCEC /* RadarFeatureSettings.h */,
Expand Down Expand Up @@ -610,6 +616,7 @@
96A5A10527AD9F7F007B960B /* RadarTrackingOptions.h in Headers */,
96A5A10927AD9F7F007B960B /* RadarContext.h in Headers */,
0107AA1226220049008AB52F /* RadarCollectionAdditions.h in Headers */,
E6EEC56E2B20F41A00DD096B /* RadarFileStorage.h in Headers */,
015C53AD29B8E8BA004F53A6 /* (null) in Headers */,
0107AA1C26220055008AB52F /* RadarPermissionsHelper.h in Headers */,
96A5A11227AD9F7F007B960B /* Radar.h in Headers */,
Expand Down Expand Up @@ -796,6 +803,7 @@
9679F4A327CD8DE200800797 /* CLLocation+Radar.m in Sources */,
0107AB08262201CE008AB52F /* RadarAPIClient.m in Sources */,
0107AB05262201CB008AB52F /* Radar.m in Sources */,
E6EEC5702B20F45D00DD096B /* RadarFileStorage.m in Sources */,
0107AB29262201F4008AB52F /* RadarTrackingOptions.m in Sources */,
0107AB2F262201FB008AB52F /* RadarUtils.m in Sources */,
0107AA8926220140008AB52F /* RadarChain.m in Sources */,
Expand Down Expand Up @@ -866,7 +874,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 3.8.10;
MARKETING_VERSION = 3.9.2-beta.1;
PRODUCT_BUNDLE_IDENTIFIER = io.radar.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -896,7 +904,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 3.8.10;
MARKETING_VERSION = 3.9.2-beta.1;
PRODUCT_BUNDLE_IDENTIFIER = io.radar.sdk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -979,7 +987,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MARKETING_VERSION = 3.8.10;
MARKETING_VERSION = 3.9.2-beta.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1037,7 +1045,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MARKETING_VERSION = 3.8.10;
MARKETING_VERSION = 3.9.2-beta.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = "-fembed-bitcode";
Expand Down
10 changes: 8 additions & 2 deletions RadarSDK/CLLocation+Radar.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@
@import Foundation;
#import "CLLocation+Radar.h"

const double DEGREE_EPSILON = 0.00000001;

@implementation CLLocation (Radar)

- (BOOL)isValid {
CLLocationDegrees lat = self.coordinate.latitude;
CLLocationDegrees lon = self.coordinate.longitude;

BOOL latitudeValid = lat != 0.0 && lat > -90.0 && lat < 90.0;
BOOL longitudeValid = lon != 0.0 && lon > -180.0 && lon < 180;
BOOL latitudeValid = ![self isDouble:lat withinDegreeEpsilonTo:0.0] && lat > -90.0 && lat < 90.0;
BOOL longitudeValid = ![self isDouble:lon withinDegreeEpsilonTo:0.0] && lon > -180.0 && lon < 180;
BOOL horizontalAccuracyValid = self.horizontalAccuracy > 0;

return latitudeValid && longitudeValid && horizontalAccuracyValid;
}

- (BOOL)isDouble:(double)firstValue withinDegreeEpsilonTo:(double)secondValue {
return fabs(firstValue - secondValue) < DEGREE_EPSILON;
}

@end
43 changes: 41 additions & 2 deletions RadarSDK/Include/Radar.h
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ logConversionWithNotification
completionHandler:(RadarSearchGeofencesCompletionHandler)completionHandler NS_SWIFT_NAME(searchGeofences(near:radius:tags:metadata:limit:completionHandler:));

/**
Autocompletes partial addresses and place names, sorted by relevance.
@deprecated Autocompletes partial addresses and place names, sorted by relevance.
@param query The partial address or place name to autocomplete.
@param near A location for the search.
Expand All @@ -899,7 +899,28 @@ logConversionWithNotification
limit:(int)limit
country:(NSString *_Nullable)country
expandUnits:(BOOL)expandUnits
completionHandler:(RadarGeocodeCompletionHandler)completionHandler NS_SWIFT_NAME(autocomplete(query:near:layers:limit:country:expandUnits:completionHandler:));
completionHandler:(RadarGeocodeCompletionHandler)completionHandler NS_SWIFT_NAME(autocomplete(query:near:layers:limit:country:expandUnits:completionHandler:)) __deprecated;

/**
Autocompletes partial addresses and place names, sorted by relevance.
@param query The partial address or place name to autocomplete.
@param near A location for the search.
@param layers Optional layer filters.
@param limit The max number of addresses to return. A number between 1 and 100.
@param country An optional country filter. A string, the unique 2-letter country code.
@param mailable Whether to only include mailable addresses. Default behavior in other function signatures is false.
@param completionHandler A completion handler.
@see https://radar.com/documentation/api#autocomplete
*/
+ (void)autocompleteQuery:(NSString *_Nonnull)query
near:(CLLocation *_Nullable)near
layers:(NSArray<NSString *> *_Nullable)layers
limit:(int)limit
country:(NSString *_Nullable)country
mailable:(BOOL)mailable
completionHandler:(RadarGeocodeCompletionHandler)completionHandler NS_SWIFT_NAME(autocomplete(query:near:layers:limit:country:mailable:completionHandler:));

/**
Autocompletes partial addresses and place names, sorted by relevance.
Expand Down Expand Up @@ -1048,6 +1069,24 @@ logConversionWithNotification
*/
+ (void)setLogLevel:(RadarLogLevel)level;

/**
Log application terminating. Include this in your application delegate's applicationWillTerminate: method.
*/
+ (void)logTermination;

/**
Log application entering background. Include this in your application delegate's applicationDidEnterBackground: method.
*/
+ (void)logBackgrounding;

/**
Log application resigning active. Include this in your application delegate's applicationWillResignActive: method.
*/
+ (void)logResigningActive;


#pragma mark - Helpers

/**
Expand Down
51 changes: 41 additions & 10 deletions RadarSDK/Radar.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ + (void)initializeWithPublishableKey:(NSString *)publishableKey {
completionHandler:^(RadarStatus status, RadarConfig *config) {
[[RadarLocationManager sharedInstance] updateTrackingFromMeta:config.meta];
[RadarSettings setFeatureSettings:config.meta.featureSettings];
[self flushLogs];
}];

}

#pragma mark - Properties
Expand Down Expand Up @@ -769,7 +771,29 @@ + (void)autocompleteQuery:(NSString *_Nonnull)query
layers:layers
limit:limit
country:country
expandUnits:expandUnits
mailable:NO
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarAddress *> *_Nullable addresses) {
if (completionHandler) {
[RadarUtils runOnMainThread:^{
completionHandler(status, addresses);
}];
}
}];
}

+ (void)autocompleteQuery:(NSString *_Nonnull)query
near:(CLLocation *_Nullable)near
layers:(NSArray *_Nullable)layers
limit:(int)limit
country:(NSString *_Nullable)country
mailable:(BOOL)mailable
completionHandler:(RadarGeocodeCompletionHandler)completionHandler {
[[RadarAPIClient sharedInstance] autocompleteQuery:query
near:near
layers:layers
limit:limit
country:country
mailable:mailable
completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray<RadarAddress *> *_Nullable addresses) {
if (completionHandler) {
[RadarUtils runOnMainThread:^{
Expand Down Expand Up @@ -962,6 +986,20 @@ + (void)setLogLevel:(RadarLogLevel)level {
[RadarSettings setLogLevel:level];
}

+ (void)logTermination {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeNone message:@"App terminating" includeDate:YES includeBattery:YES append:YES];
}

+ (void)logBackgrounding {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeNone message:@"App entering background" includeDate:YES includeBattery:YES append:YES];
[[RadarLogBuffer sharedInstance] persistLogs];
}

+ (void)logResigningActive {
[[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeNone message:@"App resigning active" includeDate:YES includeBattery:YES];
}


#pragma mark - Helpers

+ (NSString *)stringForStatus:(RadarStatus)status {
Expand Down Expand Up @@ -1182,21 +1220,14 @@ + (void)flushLogs {
return;
}

NSArray<RadarLog *> *flushableLogs = [[RadarLogBuffer sharedInstance] flushableLogs];

NSArray<RadarLog *> *flushableLogs = [[RadarLogBuffer sharedInstance] flushableLogs];
NSUInteger pendingLogCount = [flushableLogs count];
if (pendingLogCount == 0) {
return;
}

// remove logs from buffer to handle multiple flushLogs calls
[[RadarLogBuffer sharedInstance] removeLogsFromBuffer:pendingLogCount];

RadarSyncLogsAPICompletionHandler onComplete = ^(RadarStatus status) {
// if an error occurs in syncing, add the logs back to the buffer
if (status != RadarStatusSuccess) {
[[RadarLogBuffer sharedInstance] addLogsToBuffer:flushableLogs];
}
[[RadarLogBuffer sharedInstance] onFlush:status == RadarStatusSuccess logs:flushableLogs];
};

[[RadarAPIClient sharedInstance] syncLogs:flushableLogs
Expand Down
2 changes: 1 addition & 1 deletion RadarSDK/RadarAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ typedef void (^_Nonnull RadarSyncLogsAPICompletionHandler)(RadarStatus status);
layers:(NSArray<NSString *> *_Nullable)layers
limit:(int)limit
country:(NSString *_Nullable)country
expandUnits:(BOOL)expandUnits
mailable:(BOOL)mailable
completionHandler:(RadarGeocodeAPICompletionHandler _Nonnull)completionHandler;

- (void)autocompleteQuery:(NSString *_Nonnull)query
Expand Down
6 changes: 3 additions & 3 deletions RadarSDK/RadarAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ - (void)autocompleteQuery:(NSString *)query
layers:(NSArray<NSString *> *_Nullable)layers
limit:(int)limit
country:(NSString *_Nullable)country
expandUnits:(BOOL)expandUnits
mailable:(BOOL)mailable
completionHandler:(RadarGeocodeAPICompletionHandler)completionHandler {
NSString *publishableKey = [RadarSettings publishableKey];
if (!publishableKey) {
Expand All @@ -873,8 +873,8 @@ - (void)autocompleteQuery:(NSString *)query
if (country) {
[queryString appendFormat:@"&country=%@", country];
}
if (expandUnits) {
[queryString appendFormat:@"&expandUnits=true"];
if (mailable) {
[queryString appendFormat:@"&mailable=true"];
}


Expand Down
5 changes: 3 additions & 2 deletions RadarSDK/RadarBeaconManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ - (void)addCompletionHandler:(RadarBeaconCompletionHandler)completionHandler {
}

@synchronized(self) {
[self.completionHandlers addObject:completionHandler];
RadarBeaconCompletionHandler completionHandlerCopy = [completionHandler copy];
[self.completionHandlers addObject:completionHandlerCopy];

[self performSelector:@selector(timeoutWithCompletionHandler:) withObject:completionHandler afterDelay:5];
[self performSelector:@selector(timeoutWithCompletionHandler:) withObject:completionHandlerCopy afterDelay:5];
}
}

Expand Down
4 changes: 4 additions & 0 deletions RadarSDK/RadarEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ - (NSDictionary *)dictionaryValue {
[dict setValue:locationDict forKey:@"location"];
[dict setValue:@(self.replayed) forKey:@"replayed"];
[dict setValue:self.metadata forKey:@"metadata"];
NSString *createdAtString = [RadarUtils.isoDateFormatter stringFromDate:self.createdAt];
[dict setValue:createdAtString forKey:@"createdAt"];
NSString *actualCreatedAtString = [RadarUtils.isoDateFormatter stringFromDate:self.actualCreatedAt];
[dict setValue:actualCreatedAtString forKey:@"actualCreatedAt"];
return dict;
}

Expand Down
4 changes: 3 additions & 1 deletion RadarSDK/RadarFeatureSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, assign) BOOL usePersistence;
@property (nonatomic, assign) BOOL extendFlushReplays;
@property (nonatomic, assign) BOOL useLogPersistence;

/**
Initializes a new RadarFeatureSettings object with given value.
@param usePersistence A flag indicating whether to use persistence.
*/
- (instancetype)initWithUsePersistence:(BOOL)usePersistence
extendFlushReplays:(BOOL)extendFlushReplays;
extendFlushReplays:(BOOL)extendFlushReplays
useLogPersistence:(BOOL)useLogPersistence;

/**
Creates a RadarFeatureSettings object from the provided dictionary.
Expand Down
Loading

0 comments on commit 0bcaa6e

Please sign in to comment.