From 840ec42203ca30f18cfbe7b771839dc4d31fe4d8 Mon Sep 17 00:00:00 2001 From: KennyHuRadar <139801512+KennyHuRadar@users.noreply.github.com> Date: Tue, 28 Jan 2025 02:24:09 +0800 Subject: [PATCH] FENCE-2186 add countryCodes as param for search places (#430) * add countryCodes as param for search places * update tests * add migration docs * add link * add link --- Example/Example/AppDelegate.swift | 1 + MIGRATION.md | 3 +++ RadarSDK.podspec | 2 +- RadarSDK.xcodeproj/project.pbxproj | 4 ++-- RadarSDK/Include/Radar.h | 16 ++++++++++++---- RadarSDK/Radar.m | 10 ++++++++-- RadarSDK/RadarAPIClient.h | 1 + RadarSDK/RadarAPIClient.m | 5 +++++ RadarSDK/RadarUtils.m | 2 +- RadarSDKMotion.podspec | 2 +- .../RadarSDKMotion.xcodeproj/project.pbxproj | 4 ++-- RadarSDKTests/RadarSDKTests.m | 5 +++++ 12 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Example/Example/AppDelegate.swift b/Example/Example/AppDelegate.swift index b872f92fd..165b576e5 100644 --- a/Example/Example/AppDelegate.swift +++ b/Example/Example/AppDelegate.swift @@ -141,6 +141,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN chainMetadata: ["orderActive": "true"], categories: nil, groups: nil, + countryCodes: ["US"], limit: 10 ) { (status, location, places) in print("Search places: status = \(Radar.stringForStatus(status)); places = \(String(describing: places))") diff --git a/MIGRATION.md b/MIGRATION.md index 1b3e26e11..607b8066f 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,5 +1,8 @@ # Migration guides +## 3.20.x to 3.21.x +- The `Radar.searchPlaces()` method now expects an additional parameter `countryCodes` to filter results by country. See [documentation](https://radar.com/documentation/sdk/ios#search). + ## 3.12.x to 3.13.x - The `Radar.trackVerified()` method now returns `token: RadarVerifiedLocationToken`, which includes `user`, `events`, `token,`, `expiresAt`, `expiresIn`, and `passed`. The `Radar.trackVerifiedToken()` method has been removed, since `Radar.trackVerified()` now returns a signed JWT. diff --git a/RadarSDK.podspec b/RadarSDK.podspec index efdd55a06..42ea27ff8 100644 --- a/RadarSDK.podspec +++ b/RadarSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'RadarSDK' - s.version = '3.20.2' + s.version = '3.21.0' 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' } diff --git a/RadarSDK.xcodeproj/project.pbxproj b/RadarSDK.xcodeproj/project.pbxproj index b571af20e..9bc95e53f 100644 --- a/RadarSDK.xcodeproj/project.pbxproj +++ b/RadarSDK.xcodeproj/project.pbxproj @@ -1062,7 +1062,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 3.20.2; + MARKETING_VERSION = 3.21.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -1120,7 +1120,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 3.20.2; + MARKETING_VERSION = 3.21.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; OTHER_CFLAGS = "-fembed-bitcode"; diff --git a/RadarSDK/Include/Radar.h b/RadarSDK/Include/Radar.h index 0823ca000..7ea262540 100644 --- a/RadarSDK/Include/Radar.h +++ b/RadarSDK/Include/Radar.h @@ -822,6 +822,7 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status @param categories An array of categories to filter. See https://radar.com/documentation/places/categories @param groups An array of groups to filter. See https://radar.com/documentation/places/groups @param limit The max number of places to return. A number between 1 and 100. + @param countryCodes An array of country codes to filter. See https://radar.com/documentation/regions/countries @param completionHandler A completion handler. @see https://radar.com/documentation/api#search-places @@ -830,8 +831,9 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status chains:(NSArray *_Nullable)chains categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit - completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(radius:chains:categories:groups:limit:completionHandler:)); + completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(radius:chains:categories:groups:countryCodes:limit:completionHandler:)); /** Gets the device's current location, then searches for places near that location, sorted by distance. @@ -843,6 +845,7 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status @param chainMetadata Optional chain metadata filters. Keys and values must be strings. See https://radar.com/documentation/places#metadata. @param categories An array of categories to filter. See https://radar.com/documentation/places/categories @param groups An array of groups to filter. See https://radar.com/documentation/places/groups + @param countryCodes An array of country codes to filter. See https://radar.com/documentation/regions/countries @param limit The max number of places to return. A number between 1 and 100. @param completionHandler A completion handler. @@ -853,8 +856,9 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status chainMetadata:(NSDictionary *_Nullable)chainMetadata categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit - completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(radius:chains:chainMetadata:categories:groups:limit:completionHandler:)); + completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(radius:chains:chainMetadata:categories:groups:countryCodes:limit:completionHandler:)); /** Searches for places near a location, sorted by distance. @@ -866,6 +870,7 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status @param chains An array of chain slugs to filter. See https://radar.com/documentation/places/chains @param categories An array of categories to filter. See https://radar.com/documentation/places/categories @param groups An array of groups to filter. See https://radar.com/documentation/places/groups + @param countryCodes An array of country codes to filter. See https://radar.com/documentation/regions/countries @param limit The max number of places to return. A number between 1 and 100. @param completionHandler A completion handler. @@ -876,8 +881,9 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status chains:(NSArray *_Nullable)chains categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit - completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(near:radius:chains:categories:groups:limit:completionHandler:)); + completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(near:radius:chains:categories:groups:countryCodes:limit:completionHandler:)); /** Searches for places near a location, sorted by distance. @@ -890,6 +896,7 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status @param chainMetadata Optional chain metadata filters. Keys and values must be strings. See https://radar.com/documentation/places#metadata. @param categories An array of categories to filter. See https://radar.com/documentation/places/categories @param groups An array of groups to filter. See https://radar.com/documentation/places/groups + @param countryCodes An array of country codes to filter. See https://radar.com/documentation/regions/countries @param limit The max number of places to return. A number between 1 and 100. @param completionHandler A completion handler. @@ -901,8 +908,9 @@ typedef void (^_Nullable RadarLogConversionCompletionHandler)(RadarStatus status chainMetadata:(NSDictionary *_Nullable)chainMetadata categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit - completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(near:radius:chains:chainMetadata:categories:groups:limit:completionHandler:)); + completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler NS_SWIFT_NAME(searchPlaces(near:radius:chains:chainMetadata:categories:groups:countryCodes:limit:completionHandler:)); /** Gets the device's current location, then searches for geofences near that location, sorted by distance. diff --git a/RadarSDK/Radar.m b/RadarSDK/Radar.m index 82da88677..a1d5851cf 100644 --- a/RadarSDK/Radar.m +++ b/RadarSDK/Radar.m @@ -731,9 +731,10 @@ + (void)searchPlacesWithRadius:(int)radius chains:(NSArray *_Nullable)chains categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler { - [Radar searchPlacesWithRadius:radius chains:chains chainMetadata:nil categories:categories groups:groups limit:limit completionHandler:completionHandler]; + [Radar searchPlacesWithRadius:radius chains:chains chainMetadata:nil categories:categories groups:groups countryCodes:countryCodes limit:limit completionHandler:completionHandler]; } + (void)searchPlacesWithRadius:(int)radius @@ -741,6 +742,7 @@ + (void)searchPlacesWithRadius:(int)radius chainMetadata:(NSDictionary *_Nullable)chainMetadata categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler { [[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeSDKCall message:@"searchPlaces()"]; @@ -761,6 +763,7 @@ + (void)searchPlacesWithRadius:(int)radius chainMetadata:chainMetadata categories:categories groups:groups + countryCodes:countryCodes limit:limit completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray *_Nullable places) { if (completionHandler) { @@ -777,9 +780,10 @@ + (void)searchPlacesNear:(CLLocation *_Nonnull)near chains:(NSArray *_Nullable)chains categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler { - [Radar searchPlacesNear:near radius:radius chains:chains chainMetadata:nil categories:categories groups:groups limit:limit completionHandler:completionHandler]; + [Radar searchPlacesNear:near radius:radius chains:chains chainMetadata:nil categories:categories groups:groups countryCodes:countryCodes limit:limit completionHandler:completionHandler]; } + (void)searchPlacesNear:(CLLocation *_Nonnull)near @@ -788,6 +792,7 @@ + (void)searchPlacesNear:(CLLocation *_Nonnull)near chainMetadata:(NSDictionary *_Nullable)chainMetadata categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit completionHandler:(RadarSearchPlacesCompletionHandler)completionHandler { [[RadarLogger sharedInstance] logWithLevel:RadarLogLevelInfo type:RadarLogTypeSDKCall message:@"searchPlaces()"]; @@ -797,6 +802,7 @@ + (void)searchPlacesNear:(CLLocation *_Nonnull)near chainMetadata:chainMetadata categories:categories groups:groups + countryCodes:countryCodes limit:limit completionHandler:^(RadarStatus status, NSDictionary *_Nullable res, NSArray *_Nullable places) { [RadarUtils runOnMainThread:^{ diff --git a/RadarSDK/RadarAPIClient.h b/RadarSDK/RadarAPIClient.h index 160b1fabe..ff09352f5 100644 --- a/RadarSDK/RadarAPIClient.h +++ b/RadarSDK/RadarAPIClient.h @@ -111,6 +111,7 @@ typedef void (^_Nonnull RadarSyncLogsAPICompletionHandler)(RadarStatus status); chainMetadata:(NSDictionary *_Nullable)chainMetadata categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit completionHandler:(RadarSearchPlacesAPICompletionHandler _Nonnull)completionHandler; diff --git a/RadarSDK/RadarAPIClient.m b/RadarSDK/RadarAPIClient.m index 6ddb5eb50..f90cfd8d4 100644 --- a/RadarSDK/RadarAPIClient.m +++ b/RadarSDK/RadarAPIClient.m @@ -779,6 +779,7 @@ - (void)searchPlacesNear:(CLLocation *_Nonnull)near chainMetadata:(NSDictionary *_Nullable)chainMetadata categories:(NSArray *_Nullable)categories groups:(NSArray *_Nullable)groups + countryCodes:(NSArray *_Nullable)countryCodes limit:(int)limit completionHandler:(RadarSearchPlacesAPICompletionHandler)completionHandler { NSString *publishableKey = [RadarSettings publishableKey]; @@ -802,6 +803,10 @@ - (void)searchPlacesNear:(CLLocation *_Nonnull)near [queryString appendFormat:@"&groups=%@", [groups componentsJoinedByString:@","]]; } + if (countryCodes && [countryCodes count] > 0) { + [queryString appendFormat:@"&country=%@", [countryCodes componentsJoinedByString:@","]]; + } + [chainMetadata enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key, NSString *_Nonnull value, BOOL *_Nonnull stop) { [queryString appendFormat:@"&chainMetadata[%@]=\"%@\"", key, value]; }]; diff --git a/RadarSDK/RadarUtils.m b/RadarSDK/RadarUtils.m index 703b18fcd..fb468bed3 100644 --- a/RadarSDK/RadarUtils.m +++ b/RadarSDK/RadarUtils.m @@ -45,7 +45,7 @@ + (NSNumber *)timeZoneOffset { } + (NSString *)sdkVersion { - return @"3.20.2"; + return @"3.21.0"; } + (NSString *)deviceId { diff --git a/RadarSDKMotion.podspec b/RadarSDKMotion.podspec index c5de5be31..59eb2b125 100644 --- a/RadarSDKMotion.podspec +++ b/RadarSDKMotion.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'RadarSDKMotion' - s.version = '3.20.2' + s.version = '3.21.0' 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' } diff --git a/RadarSDKMotion/RadarSDKMotion.xcodeproj/project.pbxproj b/RadarSDKMotion/RadarSDKMotion.xcodeproj/project.pbxproj index 2ea99cc32..e71b3c79a 100644 --- a/RadarSDKMotion/RadarSDKMotion.xcodeproj/project.pbxproj +++ b/RadarSDKMotion/RadarSDKMotion.xcodeproj/project.pbxproj @@ -289,7 +289,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MARKETING_VERSION = 3.20.2; + MARKETING_VERSION = 3.21.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -348,7 +348,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MARKETING_VERSION = 3.20.2; + MARKETING_VERSION = 3.21.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; diff --git a/RadarSDKTests/RadarSDKTests.m b/RadarSDKTests/RadarSDKTests.m index d55798f1c..cfb93c8d5 100644 --- a/RadarSDKTests/RadarSDKTests.m +++ b/RadarSDKTests/RadarSDKTests.m @@ -898,6 +898,7 @@ - (void)test_Radar_searchPlaces_errorPermissions { chains:@[@"walmart"] categories:nil groups:nil + countryCodes:nil limit:100 completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray *_Nullable places) { XCTAssertEqual(status, RadarStatusErrorPermissions); @@ -923,6 +924,7 @@ - (void)test_Radar_searchPlaces_errorLocation { chains:@[@"walmart"] categories:nil groups:nil + countryCodes:nil limit:100 completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray *_Nullable places) { XCTAssertEqual(status, RadarStatusErrorLocation); @@ -954,6 +956,7 @@ - (void)test_Radar_searchPlaces_chains_success { chains:@[@"walmart"] categories:nil groups:nil + countryCodes:nil limit:100 completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray *_Nullable places) { XCTAssertEqual(status, RadarStatusSuccess); @@ -988,6 +991,7 @@ - (void)test_Radar_searchPlaces_chainsAndMetadata_success { chainMetadata:@{@"orderActive": @"true"} categories:nil groups:nil + countryCodes:nil limit:100 completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray *_Nullable places) { XCTAssertEqual(status, RadarStatusSuccess); @@ -1025,6 +1029,7 @@ - (void)test_Radar_searchPlacesNear_categories_success { chains:nil categories:@[@"restaurant"] groups:nil + countryCodes:nil limit:100 completionHandler:^(RadarStatus status, CLLocation *_Nullable location, NSArray *_Nullable places) { XCTAssertEqual(status, RadarStatusSuccess);