From 33a42d62cdca36f7c43df4bfb4af8bbd31f43390 Mon Sep 17 00:00:00 2001 From: ShiCheng Lu Date: Tue, 6 Aug 2024 12:58:18 -0400 Subject: [PATCH 1/6] use NSURLComponent to build query strings --- Example/Example/AppDelegate.swift | 3 + RadarSDK/RadarAPIClient.m | 412 +++++++++++++----------------- RadarSDK/RadarAPIHelper.h | 1 + RadarSDK/RadarAPIHelper.m | 6 +- 4 files changed, 186 insertions(+), 236 deletions(-) diff --git a/Example/Example/AppDelegate.swift b/Example/Example/AppDelegate.swift index 95d4dec18..d7b53c7bd 100644 --- a/Example/Example/AppDelegate.swift +++ b/Example/Example/AppDelegate.swift @@ -122,6 +122,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN Radar.searchGeofences() { (status, location, geofences) in print("Search geofences: status = \(Radar.stringForStatus(status)); geofences = \(String(describing: geofences))") } + Radar.searchGeofences(near: nil, radius: 100, tags: nil, metadata: [ "meta": "data" ], limit: 10, includeGeometry: false) { (status, location, geofences) in + print("Search geofences: status = \(Radar.stringForStatus(status)); geofences = \(String(describing: geofences))") + } } demoButton(text: "geocode") { diff --git a/RadarSDK/RadarAPIClient.m b/RadarSDK/RadarAPIClient.m index 590b93e9f..a1b62ebb5 100644 --- a/RadarSDK/RadarAPIClient.m +++ b/RadarSDK/RadarAPIClient.m @@ -86,27 +86,24 @@ - (void)getConfigForUsage:(NSString *_Nullable)usage verified:(BOOL)verified com return; } - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"installId=%@", [RadarSettings installId]]; - [queryString appendFormat:@"&sessionId=%@", [RadarSettings sessionId]]; - [queryString appendFormat:@"&id=%@", [RadarSettings _id]]; - NSString *locationAuthorization = [RadarUtils locationAuthorization]; - if (locationAuthorization) { - [queryString appendFormat:@"&locationAuthorization=%@", locationAuthorization]; - } - NSString *locationAccuracyAuthorization = [RadarUtils locationAccuracyAuthorization]; - if (locationAccuracyAuthorization) { - [queryString appendFormat:@"&locationAccuracyAuthorization=%@", locationAccuracyAuthorization]; - } + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"installId" value:[RadarSettings installId]]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"sessionId" value:[RadarSettings sessionId]]]; + NSString *_id = [RadarSettings _id]; + if (_id != nil) { + [queryString addObject:[NSURLQueryItem queryItemWithName:@"id" value:_id]]; + } + [queryString addObject:[NSURLQueryItem queryItemWithName:@"locationAuthorization" value:[RadarUtils locationAuthorization]]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"locationAccuracyAuthorization" value:[RadarUtils locationAccuracyAuthorization]]]; if (usage) { - [queryString appendFormat:@"&usage=%@", usage]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"usage" value:usage]]; } - [queryString appendFormat:@"&verified=%@", verified ? @"true" : @"false"]; - [queryString appendFormat:@"&clientSdkConfiguration=%@", [RadarUtils dictionaryToJson:[RadarSettings clientSdkConfiguration]]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"verified" value:(verified ? @"true" : @"false")]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"clientSdkConfiguration" value:[RadarUtils dictionaryToJson:[RadarSettings clientSdkConfiguration]]]]; - NSString *host = verified ? [RadarSettings verifiedHost] : [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/config?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + NSURLComponents *query = [[NSURLComponents alloc] init]; + [query setQueryItems:queryString]; + NSString *url = [NSString stringWithFormat:@"v1/config%@", query.string]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -117,6 +114,7 @@ - (void)getConfigForUsage:(NSString *_Nullable)usage verified:(BOOL)verified com sleep:NO logPayload:YES extendedTimeout:NO + verified:verified completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (!res) { return; @@ -137,9 +135,7 @@ - (void)flushReplays:(NSArray *_Nonnull)replays return; } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/track/replay", host]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + NSString *url = @"v1/track/replay"; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -153,6 +149,7 @@ - (void)flushReplays:(NSArray *_Nonnull)replays sleep:NO logPayload:NO extendedTimeout:YES + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { id eventsObj = res[@"events"]; id userObj = res[@"user"]; @@ -337,8 +334,7 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location }]; } - NSString *host = verified ? [RadarSettings verifiedHost] : [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/track", host]; + NSString *url = @"v1/track"; url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -364,12 +360,13 @@ - (void)trackWithLocation:(CLLocation *_Nonnull)location }]; } else { [self.apiHelper requestWithMethod:@"POST" - url:url - headers:headers - params:requestParams + url:url + headers:headers + params:requestParams sleep:YES - logPayload:YES - extendedTimeout:NO + logPayload:YES + extendedTimeout:NO + verified:verified completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { if (options.replay == RadarTrackingOptionsReplayAll) { @@ -496,9 +493,7 @@ - (void)verifyEventId:(NSString *)eventId verification:(RadarEventVerification)v params[@"verifiedPlaceId"] = verifiedPlaceId; } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/events/%@/verification", host, eventId]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + NSString *url = [NSString stringWithFormat:@"v1/events/%@/verification", eventId]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -509,6 +504,7 @@ - (void)verifyEventId:(NSString *)eventId verification:(RadarEventVerification)v sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res){ }]; @@ -552,9 +548,7 @@ - (void)createTripWithOptions:(RadarTripOptions *)options completionHandler:(Rad params[@"approachingThreshold"] = [NSString stringWithFormat:@"%d", options.approachingThreshold]; } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/trips", host]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + NSString *url = [NSString stringWithFormat:@"v1/trips"]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -565,6 +559,7 @@ - (void)createTripWithOptions:(RadarTripOptions *)options completionHandler:(Rad sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -623,8 +618,7 @@ - (void)updateTripWithOptions:(RadarTripOptions *)options status:(RadarTripStatu params[@"approachingThreshold"] = [NSString stringWithFormat:@"%d", options.approachingThreshold]; } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/trips/%@/update", host, options.externalId]; + NSString *url = [NSString stringWithFormat:@"v1/trips/%@/update", options.externalId]; url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -636,6 +630,7 @@ - (void)updateTripWithOptions:(RadarTripOptions *)options status:(RadarTripStatu sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -660,21 +655,25 @@ - (void)getContextForLocation:(CLLocation *_Nonnull)location completionHandler:( return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"coordinates=%.06f,%.06f", location.coordinate.latitude, location.coordinate.longitude]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"coordinates" + value:[NSString stringWithFormat:@"%.06f,%.06f", location.coordinate.latitude, location.coordinate.longitude]]]; - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/context?%@", host, queryString]; + NSURLComponents* url = [[NSURLComponents alloc] initWithString:@"v1/context"]; + [url setQueryItems:queryString]; + + NSLog(@"TEST: %@", url.string); NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -703,39 +702,40 @@ - (void)searchPlacesNear:(CLLocation *_Nonnull)near return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - int finalLimit = MIN(limit, 100); - - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"near=%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]; - [queryString appendFormat:@"&radius=%d", radius]; - [queryString appendFormat:@"&limit=%d", finalLimit]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"near" + value:[NSString stringWithFormat:@"%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"radius" value:@(radius).stringValue]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"limit" value:@(MIN(limit, 100)).stringValue]]; if (chains && [chains count] > 0) { - [queryString appendFormat:@"&chains=%@", [chains componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"chains" value:[chains componentsJoinedByString:@","]]]; } if (categories && [categories count] > 0) { - [queryString appendFormat:@"&categories=%@", [categories componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"categories" value:[categories componentsJoinedByString:@","]]]; } if (groups && [groups count] > 0) { - [queryString appendFormat:@"&groups=%@", [groups componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"groups" value:[groups componentsJoinedByString:@","]]]; } [chainMetadata enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key, NSString *_Nonnull value, BOOL *_Nonnull stop) { - [queryString appendFormat:@"&chainMetadata[%@]=\"%@\"", key, value]; + [queryString addObject:[NSURLQueryItem queryItemWithName:[NSString stringWithFormat:@"chainMetadata[%@]", key] + value:[NSString stringWithFormat:@"\"%@\"", value]]]; }]; - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/search/places?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + NSURLComponents* url = [[NSURLComponents alloc] initWithString:@"v1/search/places"]; + [url setQueryItems:queryString]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -763,39 +763,45 @@ - (void)searchGeofencesNear:(CLLocation *_Nonnull)near return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - int finalLimit = MIN(limit, 1000); - - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"near=%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"near" + value:[NSString stringWithFormat:@"%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]]]; + if (radius > 0) { - [queryString appendFormat:@"&radius=%d", radius]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"radius" + value:@(radius).stringValue]]; + } - [queryString appendFormat:@"&limit=%d", finalLimit]; + + [queryString addObject:[NSURLQueryItem queryItemWithName:@"limit" + value:@(MIN(limit, 1000)).stringValue]]; if (tags && [tags count] > 0) { - [queryString appendFormat:@"&tags=%@", [tags componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"tags" + value:[tags componentsJoinedByString:@","]]]; } if (metadata && [metadata count] > 0) { for (NSString *key in metadata) { - [queryString appendFormat:@"&metadata[%@]=%@", key, metadata[key]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:[NSString stringWithFormat:@"metadata[%@]", key] + value:[NSString stringWithFormat:@"%@", metadata[key]]]]; } } - [queryString appendFormat:@"&includeGeometry=%@", includeGeometry ? @"true" : @"false"]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"includeGeometry" + value:(includeGeometry ? @"true" : @"false")]]; + + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/search/geofences%@"]; + [url setQueryItems:queryString]; - - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/search/geofences?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -817,25 +823,24 @@ - (void)searchBeaconsNear:(CLLocation *)near radius:(int)radius limit:(int)limit return completionHandler(RadarStatusErrorPublishableKey, nil, nil, nil); } - int finalLimit = MIN(limit, 100); - - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"near=%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]; - [queryString appendFormat:@"&radius=%d", radius]; - [queryString appendFormat:@"&limit=%d", finalLimit]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"near" + value:[NSString stringWithFormat:@"%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"radius" value:@(radius).stringValue]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"limit=%d" value:@(MIN(limit, 100)).stringValue]]; - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/search/beacons?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/search/beacons"]; + [url setQueryItems:queryString]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil, nil); @@ -881,40 +886,38 @@ - (void)autocompleteQuery:(NSString *)query return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - int finalLimit = MIN(limit, 100); - - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"query=%@", query]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"query" value:query]]; if (near) { - [queryString appendFormat:@"&near=%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"near" + value:[NSString stringWithFormat:@"%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]]]; } if (layers && layers.count > 0) { - [queryString appendFormat:@"&layers=%@", [layers componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"layers" value:[layers componentsJoinedByString:@","]]]; } if (limit) { - [queryString appendFormat:@"&limit=%d", finalLimit]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"limit" value:@(MIN(limit, 100)).stringValue]]; } if (country) { - [queryString appendFormat:@"&country=%@", country]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"country" value:country]]; } if (mailable) { - [queryString appendFormat:@"&mailable=true"]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"mailable" value:@"true"]]; } - - - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/search/autocomplete?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/search/autocomplete"]; + [url setQueryItems:queryString]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -943,79 +946,34 @@ - (void)autocompleteQuery:(NSString *)query int finalLimit = MIN(limit, 100); - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"query=%@", query]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"query" value:query]]; if (near) { - [queryString appendFormat:@"&near=%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"near" value:[NSString stringWithFormat:@"%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]]]; } if (layers && layers.count > 0) { - [queryString appendFormat:@"&layers=%@", [layers componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"layers" value:[layers componentsJoinedByString:@","]]]; } if (limit) { - [queryString appendFormat:@"&limit=%d", finalLimit]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"limit" value:@(MIN(limit, 100)).stringValue]]; } if (country) { - [queryString appendFormat:@"&country=%@", country]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"country" value:country]]; } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/search/autocomplete?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - - NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; - - [self.apiHelper requestWithMethod:@"GET" - url:url - headers:headers - params:nil - sleep:NO - logPayload:YES - extendedTimeout:NO - completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { - if (status != RadarStatusSuccess || !res) { - return completionHandler(status, nil, nil); - } - - id addressesObj = res[@"addresses"]; - NSArray *addresses = [RadarAddress addressesFromObject:addressesObj]; - if (addresses) { - return completionHandler(RadarStatusSuccess, res, addresses); - } - - completionHandler(RadarStatusErrorServer, nil, nil); - }]; -} - -- (void)autocompleteQuery:(NSString *)query near:(CLLocation *_Nullable)near limit:(int)limit completionHandler:(RadarGeocodeAPICompletionHandler)completionHandler { - NSString *publishableKey = [RadarSettings publishableKey]; - if (!publishableKey) { - return completionHandler(RadarStatusErrorPublishableKey, nil, nil); - } - - int finalLimit = MIN(limit, 100); - - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"query=%@", query]; - if (near) { - [queryString appendFormat:@"&near=%.06f,%.06f", near.coordinate.latitude, near.coordinate.longitude]; - } - if (limit) { - [queryString appendFormat:@"&limit=%d", finalLimit]; - } - - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/search/autocomplete?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/search/autocomplete"]; + [url setQueryItems:queryString]; + NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -1037,7 +995,7 @@ - (void)validateAddress:(RadarAddress *)address completionHandler:(RadarValidate return completionHandler(RadarStatusErrorPublishableKey, nil, nil, RadarAddressVerificationStatusNone); } - NSMutableString *queryString = [NSMutableString new]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; if (!address.countryCode || !address.stateCode || !address.city || !address.number || !address.postalCode || !address.street) { if (completionHandler) { [RadarUtils runOnMainThread:^{ @@ -1047,31 +1005,32 @@ - (void)validateAddress:(RadarAddress *)address completionHandler:(RadarValidate return; } else { - [queryString appendFormat:@"countryCode=%@", address.countryCode]; - [queryString appendFormat:@"&stateCode=%@", address.stateCode]; - [queryString appendFormat:@"&city=%@", address.city]; - [queryString appendFormat:@"&number=%@", address.number]; - [queryString appendFormat:@"&postalCode=%@", address.postalCode]; - [queryString appendFormat:@"&street=%@", address.street]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"countryCode" value:address.countryCode]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"stateCode" value:address.stateCode]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"city" value:address.city]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"number" value:address.number]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"postalCode" value:address.postalCode]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"street" value:address.street]]; } if (address.unit) { - [queryString appendFormat:@"&unit=%@", address.unit]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"unit" value:address.unit]]; } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/addresses/validate?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/addresses/validate"]; + [url setQueryItems:queryString]; + + NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil, RadarAddressVerificationStatusNone); @@ -1109,28 +1068,28 @@ - (void)geocodeAddress:(NSString *)query return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"query=%@", query]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"query" value:query]]; if (layers && layers.count > 0) { - [queryString appendFormat:@"&layers=%@", [layers componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"layers" value:[layers componentsJoinedByString:@","]]]; } if (countries && countries.count > 0) { - [queryString appendFormat:@"&country=%@", [countries componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"country" value:[countries componentsJoinedByString:@","]]]; } - - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/geocode/forward?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - + + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/geocode/forward"]; + [url setQueryItems:queryString]; + NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -1154,25 +1113,26 @@ - (void)reverseGeocodeLocation:(CLLocation *)location return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"coordinates=%.06f,%.06f", location.coordinate.latitude, location.coordinate.longitude]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"coordinates" + value:[NSString stringWithFormat:@"%.06f,%.06f", location.coordinate.latitude, location.coordinate.longitude]]]; if (layers && layers.count > 0) { - [queryString appendFormat:@"&layers=%@", [layers componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"layers" value:[layers componentsJoinedByString:@","]]]; } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/geocode/reverse?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/geocode/reverse"]; + [url setQueryItems:queryString]; + NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -1194,8 +1154,7 @@ - (void)ipGeocodeWithCompletionHandler:(RadarIPGeocodeAPICompletionHandler)compl return completionHandler(RadarStatusErrorPublishableKey, nil, nil, NO); } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/geocode/ip", host]; + NSString *url = @"v1/geocode/ip"; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -1206,6 +1165,7 @@ - (void)ipGeocodeWithCompletionHandler:(RadarIPGeocodeAPICompletionHandler)compl sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil, NO); @@ -1239,9 +1199,9 @@ - (void)getDistanceFromOrigin:(CLLocation *)origin return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - NSMutableString *queryString = [NSMutableString new]; - [queryString appendFormat:@"origin=%.06f,%.06f", origin.coordinate.latitude, origin.coordinate.longitude]; - [queryString appendFormat:@"&destination=%.06f,%.06f", destination.coordinate.latitude, destination.coordinate.longitude]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"origin" value:[NSString stringWithFormat:@"%.06f,%.06f", origin.coordinate.latitude, origin.coordinate.longitude]]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"destination" value:[NSString stringWithFormat:@"%.06f,%.06f", destination.coordinate.latitude, destination.coordinate.longitude]]]; NSMutableArray *modesArr = [NSMutableArray array]; if (modes & RadarRouteModeFoot) { [modesArr addObject:@"foot"]; @@ -1258,32 +1218,32 @@ - (void)getDistanceFromOrigin:(CLLocation *)origin if (modes & RadarRouteModeMotorbike) { [modesArr addObject:@"motorbike"]; } - [queryString appendFormat:@"&modes=%@", [modesArr componentsJoinedByString:@","]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"modes" value:[modesArr componentsJoinedByString:@","]]]; NSString *unitsStr; if (units == RadarRouteUnitsMetric) { unitsStr = @"metric"; } else { unitsStr = @"imperial"; } - [queryString appendFormat:@"&units=%@", unitsStr]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"units" value:unitsStr]]; if (geometryPoints > 1) { - [queryString appendFormat:@"&geometryPoints=%d", geometryPoints]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"geometryPoints" value:@(geometryPoints).stringValue]]; } - [queryString appendString:@"&geometry=linestring"]; - - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/route/distance?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"&geometry" value:@"linestring"]]; + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/route/distance"]; + [url setQueryItems:queryString]; + NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -1309,57 +1269,42 @@ - (void)getMatrixFromOrigins:(NSArray *)origins return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - NSMutableString *queryString = [NSMutableString new]; - [queryString appendString:@"origins="]; + NSMutableArray *queryString = [[NSMutableArray alloc] init]; + + NSMutableArray *originsString = [[NSMutableArray alloc] init]; for (int i = 0; i < origins.count; i++) { - CLLocation *origin = origins[i]; - [queryString appendFormat:@"%.06f,%.06f", origin.coordinate.latitude, origin.coordinate.longitude]; - if (i < origins.count - 1) { - [queryString appendString:@"|"]; - } + [originsString addObject:[NSString stringWithFormat:@"%.06f,%.06f", origins[i].coordinate.latitude, origins[i].coordinate.longitude]]; } - [queryString appendString:@"&destinations="]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"origins" value:[originsString componentsJoinedByString:@"|"]]]; + + NSMutableArray *destinationsString = [[NSMutableArray alloc] init]; for (int i = 0; i < destinations.count; i++) { - CLLocation *destination = destinations[i]; - [queryString appendFormat:@"%.06f,%.06f", destination.coordinate.latitude, destination.coordinate.longitude]; - if (i < destinations.count - 1) { - [queryString appendString:@"|"]; - } + [destinationsString addObject:[NSString stringWithFormat:@"%.06f,%.06f", origins[i].coordinate.latitude, origins[i].coordinate.longitude]]; } - NSString *modeStr; - if (mode == RadarRouteModeFoot) { - modeStr = @"foot"; - } else if (mode == RadarRouteModeBike) { - modeStr = @"bike"; - } else if (mode == RadarRouteModeCar) { - modeStr = @"car"; - } else if (mode == RadarRouteModeTruck) { - modeStr = @"truck"; - } else if (mode == RadarRouteModeMotorbike) { - modeStr = @"motorbike"; - } - [queryString appendFormat:@"&mode=%@", modeStr]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"destinations" value:[originsString componentsJoinedByString:@"|"]]]; + + [queryString addObject:[NSURLQueryItem queryItemWithName:@"mode" value:[Radar stringForMode:mode]]]; NSString *unitsStr; if (units == RadarRouteUnitsMetric) { unitsStr = @"metric"; } else { unitsStr = @"imperial"; } - [queryString appendFormat:@"&units=%@", unitsStr]; - - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/route/matrix?%@", host, queryString]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + [queryString addObject:[NSURLQueryItem queryItemWithName:@"units" value:unitsStr]]; + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/route/matrix"]; + [url setQueryItems:queryString]; + NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -1392,10 +1337,8 @@ - (void)sendEvent:(NSString *)conversionName params[@"type"] = conversionName; params[@"metadata"] = metadata; - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/events", host]; - url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - + NSString *url = @"v1/events"; + NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"POST" @@ -1405,6 +1348,7 @@ - (void)sendEvent:(NSString *)conversionName sleep:NO logPayload:YES extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { if (status != RadarStatusSuccess || !res) { return completionHandler(status, nil, nil); @@ -1429,8 +1373,7 @@ - (void)syncLogs:(NSArray *)logs completionHandler:(RadarSyncLogsAPI return completionHandler(RadarStatusErrorPublishableKey); } - NSString *host = [RadarSettings host]; - NSString *url = [NSString stringWithFormat:@"%@/v1/logs", host]; + NSString *url = @"v1/logs"; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -1453,6 +1396,7 @@ - (void)syncLogs:(NSArray *)logs completionHandler:(RadarSyncLogsAPI sleep:NO logPayload:NO // avoid logging the logging call extendedTimeout:NO + verified:NO completionHandler:^(RadarStatus status, NSDictionary *_Nullable res) { return completionHandler(status); }]; diff --git a/RadarSDK/RadarAPIHelper.h b/RadarSDK/RadarAPIHelper.h index 2f12ba137..24ec5fdd3 100644 --- a/RadarSDK/RadarAPIHelper.h +++ b/RadarSDK/RadarAPIHelper.h @@ -22,6 +22,7 @@ typedef void (^_Nullable RadarAPICompletionHandler)(RadarStatus status, NSDictio sleep:(BOOL)sleep logPayload:(BOOL)logPayload extendedTimeout:(BOOL)extendedTimeout + verified:(BOOL)verified completionHandler:(RadarAPICompletionHandler _Nullable)completionHandler; @end diff --git a/RadarSDK/RadarAPIHelper.m b/RadarSDK/RadarAPIHelper.m index 017e7d6a6..36069ad32 100644 --- a/RadarSDK/RadarAPIHelper.m +++ b/RadarSDK/RadarAPIHelper.m @@ -37,15 +37,17 @@ - (void)requestWithMethod:(NSString *)method sleep:(BOOL)sleep logPayload:(BOOL)logPayload extendedTimeout:(BOOL)extendedTimeout + verified:(BOOL)verified completionHandler:(RadarAPICompletionHandler)completionHandler { dispatch_async(self.queue, ^{ if (sleep) { dispatch_semaphore_wait(self.semaphore, DISPATCH_TIME_FOREVER); } - NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]]; + NSURL *host = [NSURL URLWithString:(verified ? [RadarSettings verifiedHost] : [RadarSettings host])]; + NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url relativeToURL:host]]; req.HTTPMethod = method; - + NSString * paramJsonStr = [RadarUtils dictionaryToJson:params]; NSString * headersJsonStr = [RadarUtils dictionaryToJson:headers]; From 8cbeb376fb95f2954fa536f72805bc27fab739f7 Mon Sep 17 00:00:00 2001 From: ShiCheng Lu Date: Tue, 6 Aug 2024 13:07:38 -0400 Subject: [PATCH 2/6] fix some issues --- Example/Example/AppDelegate.swift | 2 +- RadarSDK/RadarAPIClient.m | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Example/Example/AppDelegate.swift b/Example/Example/AppDelegate.swift index d7b53c7bd..5ec98c6c2 100644 --- a/Example/Example/AppDelegate.swift +++ b/Example/Example/AppDelegate.swift @@ -122,7 +122,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIWindowSceneDelegate, UN Radar.searchGeofences() { (status, location, geofences) in print("Search geofences: status = \(Radar.stringForStatus(status)); geofences = \(String(describing: geofences))") } - Radar.searchGeofences(near: nil, radius: 100, tags: nil, metadata: [ "meta": "data" ], limit: 10, includeGeometry: false) { (status, location, geofences) in + Radar.searchGeofences(near: nil, radius: 1000, tags: nil, metadata: [ "meta": "data" ], limit: 10, includeGeometry: false) { (status, location, geofences) in print("Search geofences: status = \(Radar.stringForStatus(status)); geofences = \(String(describing: geofences))") } } diff --git a/RadarSDK/RadarAPIClient.m b/RadarSDK/RadarAPIClient.m index a1b62ebb5..3c8bb4ce5 100644 --- a/RadarSDK/RadarAPIClient.m +++ b/RadarSDK/RadarAPIClient.m @@ -101,14 +101,13 @@ - (void)getConfigForUsage:(NSString *_Nullable)usage verified:(BOOL)verified com [queryString addObject:[NSURLQueryItem queryItemWithName:@"verified" value:(verified ? @"true" : @"false")]]; [queryString addObject:[NSURLQueryItem queryItemWithName:@"clientSdkConfiguration" value:[RadarUtils dictionaryToJson:[RadarSettings clientSdkConfiguration]]]]; - NSURLComponents *query = [[NSURLComponents alloc] init]; - [query setQueryItems:queryString]; - NSString *url = [NSString stringWithFormat:@"v1/config%@", query.string]; + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/config"]; + [url setQueryItems:queryString]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; [self.apiHelper requestWithMethod:@"GET" - url:url + url:url.string headers:headers params:nil sleep:NO @@ -789,7 +788,7 @@ - (void)searchGeofencesNear:(CLLocation *_Nonnull)near [queryString addObject:[NSURLQueryItem queryItemWithName:@"includeGeometry" value:(includeGeometry ? @"true" : @"false")]]; - NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/search/geofences%@"]; + NSURLComponents *url = [[NSURLComponents alloc] initWithString:@"v1/search/geofences"]; [url setQueryItems:queryString]; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; From 563001907dcb410292e975d5726a97a5a8750840 Mon Sep 17 00:00:00 2001 From: ShiCheng Lu Date: Tue, 6 Aug 2024 13:16:38 -0400 Subject: [PATCH 3/6] remove debug log --- RadarSDK/RadarAPIClient.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/RadarSDK/RadarAPIClient.m b/RadarSDK/RadarAPIClient.m index 3c8bb4ce5..7a59f2997 100644 --- a/RadarSDK/RadarAPIClient.m +++ b/RadarSDK/RadarAPIClient.m @@ -547,7 +547,7 @@ - (void)createTripWithOptions:(RadarTripOptions *)options completionHandler:(Rad params[@"approachingThreshold"] = [NSString stringWithFormat:@"%d", options.approachingThreshold]; } - NSString *url = [NSString stringWithFormat:@"v1/trips"]; + NSString *url = @"v1/trips"; NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; @@ -660,8 +660,6 @@ - (void)getContextForLocation:(CLLocation *_Nonnull)location completionHandler:( NSURLComponents* url = [[NSURLComponents alloc] initWithString:@"v1/context"]; [url setQueryItems:queryString]; - - NSLog(@"TEST: %@", url.string); NSDictionary *headers = [RadarAPIClient headersWithPublishableKey:publishableKey]; From 1fe095097e34e6a8979c05560e261229727a743d Mon Sep 17 00:00:00 2001 From: ShiCheng Lu Date: Tue, 6 Aug 2024 13:19:13 -0400 Subject: [PATCH 4/6] update API mock helper signature --- RadarSDKTests/RadarAPIHelperMock.m | 1 + 1 file changed, 1 insertion(+) diff --git a/RadarSDKTests/RadarAPIHelperMock.m b/RadarSDKTests/RadarAPIHelperMock.m index 5e81877ce..397c9438a 100644 --- a/RadarSDKTests/RadarAPIHelperMock.m +++ b/RadarSDKTests/RadarAPIHelperMock.m @@ -32,6 +32,7 @@ - (void)requestWithMethod:(NSString *)method sleep:(BOOL)sleep logPayload:(BOOL)logPayload extendedTimeout:(BOOL)extendedTimeout + verified:(BOOL)verified completionHandler:(RadarAPICompletionHandler)completionHandler { NSDictionary *mockResponseForUrl = self.mockResponses[url]; From 8e9b0dc5647a8dfac819d713d9ff1fa65385cb45 Mon Sep 17 00:00:00 2001 From: ShiCheng Lu Date: Tue, 6 Aug 2024 13:51:28 -0400 Subject: [PATCH 5/6] fix test --- RadarSDKTests/RadarAPIHelperMock.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RadarSDKTests/RadarAPIHelperMock.m b/RadarSDKTests/RadarAPIHelperMock.m index 397c9438a..050b12be6 100644 --- a/RadarSDKTests/RadarAPIHelperMock.m +++ b/RadarSDKTests/RadarAPIHelperMock.m @@ -34,7 +34,10 @@ - (void)requestWithMethod:(NSString *)method extendedTimeout:(BOOL)extendedTimeout verified:(BOOL)verified completionHandler:(RadarAPICompletionHandler)completionHandler { - NSDictionary *mockResponseForUrl = self.mockResponses[url]; + NSURL *host = [NSURL URLWithString:(verified ? @"https://api-verified.radar.io" : @"https://api.radar.io")]; + NSString *urlString = [[NSURL URLWithString:url relativeToURL:host] absoluteString]; + + NSDictionary *mockResponseForUrl = self.mockResponses[urlString]; if (mockResponseForUrl) { completionHandler(self.mockStatus, mockResponseForUrl); From 48ea183aad031ce70c059d33b22cc755535d8fcd Mon Sep 17 00:00:00 2001 From: ShiCheng Lu Date: Wed, 7 Aug 2024 16:23:29 -0400 Subject: [PATCH 6/6] remove unused variable --- RadarSDK/RadarAPIClient.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/RadarSDK/RadarAPIClient.m b/RadarSDK/RadarAPIClient.m index 7a59f2997..c62122a3c 100644 --- a/RadarSDK/RadarAPIClient.m +++ b/RadarSDK/RadarAPIClient.m @@ -941,8 +941,6 @@ - (void)autocompleteQuery:(NSString *)query return completionHandler(RadarStatusErrorPublishableKey, nil, nil); } - int finalLimit = MIN(limit, 100); - NSMutableArray *queryString = [[NSMutableArray alloc] init]; [queryString addObject:[NSURLQueryItem queryItemWithName:@"query" value:query]]; if (near) {