diff --git a/geocoding_ios/CHANGELOG.md b/geocoding_ios/CHANGELOG.md index e33c3e1..e3fc531 100644 --- a/geocoding_ios/CHANGELOG.md +++ b/geocoding_ios/CHANGELOG.md @@ -1,7 +1,9 @@ -## 2.4.0 +## 3.0.0 + **Breaking Change** * Fixes to configure the locale. * Removes the `localeIdentifier` argument from all methods. Use method `setLocaleIdentifier` to configure the locale. + * Removes old iOS version checks and expects iOS 12 and above. (minimal iOS version is 12 per 2.2.0) ## 2.3.0 diff --git a/geocoding_ios/ios/Classes/GeocodingHandler.m b/geocoding_ios/ios/Classes/GeocodingHandler.m index 504231c..3e12635 100644 --- a/geocoding_ios/ios/Classes/GeocodingHandler.m +++ b/geocoding_ios/ios/Classes/GeocodingHandler.m @@ -31,42 +31,16 @@ - (void) geocodeFromAddress: (NSString *)address return; } - if (@available(iOS 11.0, *)) { - [_geocoder geocodeAddressString:address - inRegion:nil - preferredLocale:locale - completionHandler:^(NSArray< CLPlacemark *> *__nullable placemarks, NSError *__nullable error) - { - [GeocodingHandler completeGeocodingWith:placemarks - error:error - success:successHandler - failure:failureHandler]; - }]; - } else { - NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults]; - NSArray *defaultLanguages; - - if (locale != nil) { - defaultLanguages = [standardUserDefaults arrayForKey:@"AppleLanguages"]; - [standardUserDefaults setValue:[GeocodingHandler languageCode:locale] - forKey:@"AppleLanguages"]; - } - - [_geocoder geocodeAddressString:address - completionHandler:^(NSArray< CLPlacemark *> *__nullable placemarks, NSError *__nullable error) { - - [GeocodingHandler completeGeocodingWith:placemarks - error:error - success:successHandler - failure:failureHandler]; - - if (locale != nil) { - [standardUserDefaults setValue:defaultLanguages - forKey:@"AppleLanguages"]; - } - }]; - } - + [_geocoder geocodeAddressString:address + inRegion:nil + preferredLocale:locale + completionHandler:^(NSArray< CLPlacemark *> *__nullable placemarks, NSError *__nullable error) + { + [GeocodingHandler completeGeocodingWith:placemarks + error:error + success:successHandler + failure:failureHandler]; + }]; return; } @@ -74,39 +48,14 @@ - (void) geocodeToAddress: (CLLocation *)location locale: (NSLocale *)locale success: (GeocodingSuccess)successHandler failure: (GeocodingFailure)failureHandler { - - if (@available(iOS 11.0, *)) { - [_geocoder reverseGeocodeLocation:location - preferredLocale:locale - completionHandler:^(NSArray< CLPlacemark *> *__nullable placemarks, NSError *__nullable error) { - [GeocodingHandler completeGeocodingWith:placemarks - error:error - success:successHandler - failure:failureHandler]; - }]; - - } else { - NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults]; - NSArray *defaultLanguages; - - if (locale != nil) { - defaultLanguages = [standardUserDefaults arrayForKey:@"AppleLanguages"]; - [standardUserDefaults setValue:[GeocodingHandler languageCode:locale] - forKey:@"AppleLanguages"]; - } - - [_geocoder reverseGeocodeLocation:location - completionHandler:^(NSArray< CLPlacemark *> *__nullable placemarks, NSError *__nullable error) { - [GeocodingHandler completeGeocodingWith:placemarks - error:error - success:successHandler - failure:failureHandler]; - - if (locale != nil) { - [standardUserDefaults setValue:defaultLanguages forKey:@"AppleLanguages"]; - } - }]; - } + [_geocoder reverseGeocodeLocation:location + preferredLocale:locale + completionHandler:^(NSArray< CLPlacemark *> *__nullable placemarks, NSError *__nullable error) { + [GeocodingHandler completeGeocodingWith:placemarks + error:error + success:successHandler + failure:failureHandler]; + }]; } + (void) completeGeocodingWith: (NSArray *) placemarks @@ -128,10 +77,6 @@ + (void) completeGeocodingWith: (NSArray *) placemarks + (NSString *) languageCode:(NSLocale *)locale { - if (@available(iOS 10.0, *)) { - return [locale languageCode]; - } else { - return [[locale localeIdentifier] substringToIndex:2]; - } + return [locale languageCode]; } @end diff --git a/geocoding_ios/pubspec.yaml b/geocoding_ios/pubspec.yaml index 2b78ba4..b979d26 100644 --- a/geocoding_ios/pubspec.yaml +++ b/geocoding_ios/pubspec.yaml @@ -1,6 +1,6 @@ name: geocoding_ios description: A Flutter Geocoding plugin which provides easy geocoding and reverse-geocoding features. -version: 2.4.0 +version: 3.0.0 repository: https://github.com/baseflow/flutter-geocoding/tree/main/geocoding_ios issue_tracker: https://github.com/Baseflow/flutter-geocoding/issues