diff --git a/README.md b/README.md index efafd26..8421dfb 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ both iOS and Android will return the following object: ## Notes ### iOS -iOS does not allow sending multiple geocoding requests simultaneously. +iOS does not allow sending multiple geocoding requests simultaneously, unless you enable the fallbackToGoogle to handle the parallel calls when an native iOS request is active. ### Android geocoding may not work on older android devices (4.1) and will not work if Google play services are not available. diff --git a/ios/RNGeocoder/RNGeocoder.m b/ios/RNGeocoder/RNGeocoder.m index 636aa91..5ad122b 100644 --- a/ios/RNGeocoder/RNGeocoder.m +++ b/ios/RNGeocoder/RNGeocoder.m @@ -30,7 +30,9 @@ @implementation RNGeocoder self.geocoder = [[CLGeocoder alloc] init]; } - [self.geocoder cancelGeocode]; + if (self.geocoder.geocoding) { + return reject(@"NOT_AVAILABLE", @"geocodePosition busy", nil); + } [self.geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { @@ -55,16 +57,18 @@ @implementation RNGeocoder self.geocoder = [[CLGeocoder alloc] init]; } - [self.geocoder cancelGeocode]; + if (self.geocoder.geocoding) { + return reject(@"NOT_AVAILABLE", @"geocodeAddress busy", nil); + } [self.geocoder geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error) { if (error) { if (placemarks.count == 0) { - return reject(@"NOT_FOUND", @"geocodePosition failed", error); + return reject(@"NOT_FOUND", @"geocodeAddress failed", error); } - return reject(@"ERROR", @"geocodePosition failed", error); + return reject(@"ERROR", @"geocodeAddress failed", error); } resolve([self placemarksToDictionary:placemarks]);