mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 913 forks source link

Error PluginGeocoder.m iOS 17 #2930

Open keriroso opened 2 weeks ago

keriroso commented 2 weeks ago

I'm submitting a ... (check one with "x")

OS: (check one with "x")

Current behavior:

Hello, I am experiencing an issue with one of my applications. The Cordova-Google-Maps plugin is failing on iOS 17, specifically in the initialization of the Geocoder plugin that uses NSLocale ISOCountryCodes to get a list of country codes.

Expected behavior:

Screen capture or video record: Captura de pantalla 2024-05-14 a la(s) 09 28 37

Captura de pantalla 2024-05-14 a la(s) 09 29 47

Related code, data or error log (please format your code or data): Reason: In iOS 17, the option to extract NSLocale ISOCountryCodes country codes in Objective-c is not supported in this new version of the operating system, resulting in a nil value being returned and causing the application to terminate unexpectedly.

Action taken: A manual adjustment was made to the plugin by validating an action found in the Apple developer manual, The system version is validated and based on this, a different action is taken for iOS 17, regionCode is used and not IsoCountryCodes.

 NSArray *countryCodes;
    if (@available(iOS 17.0, *)) {
      // Use regionCode for iOS 17 and above
      countryCodes = [[NSLocale currentLocale] regionCode] ? @[ [[NSLocale currentLocale] regionCode] ] : [NSLocale ISOCountryCodes];
    } else {
      // Use ISOCountryCodes for versions below iOS 17
      countryCodes = [NSLocale ISOCountryCodes];
    }