Skip to content

Commit

Permalink
removed old version checks. Adds breaking change.
Browse files Browse the repository at this point in the history
  • Loading branch information
TimHoogstrate committed Mar 4, 2024
1 parent 7f31599 commit bb636ef
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 76 deletions.
4 changes: 3 additions & 1 deletion geocoding_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
93 changes: 19 additions & 74 deletions geocoding_ios/ios/Classes/GeocodingHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,82 +31,31 @@ - (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<NSString * > *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;
}

- (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<NSString * > *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<CLPlacemark *> *) placemarks
Expand All @@ -128,10 +77,6 @@ + (void) completeGeocodingWith: (NSArray<CLPlacemark *> *) placemarks


+ (NSString *) languageCode:(NSLocale *)locale {
if (@available(iOS 10.0, *)) {
return [locale languageCode];
} else {
return [[locale localeIdentifier] substringToIndex:2];
}
return [locale languageCode];
}
@end
2 changes: 1 addition & 1 deletion geocoding_ios/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit bb636ef

Please sign in to comment.