mattermoran / map_launcher

Flutter plugin for launching maps
MIT License
259 stars 116 forks source link

iOS Crash on showMarker [canOpenURL: failed for URL] #98

Closed samuele-besoli-mndl closed 2 years ago

samuele-besoli-mndl commented 2 years ago

Hello, I'm using this package as it follow

final availableMaps = await MapLauncher.installedMaps;
if (availableMaps.length > 1) {
  MapsSheet.show(
    context: context,
    onMapTap: (map) {
      map.showMarker(
        coords: Coords(
          details.location.position.latitude,
          details.location.position.longitude,
        ),
        title: details.address,
      );
      Navigator.pop(context);
    },
  );
} else {
  availableMaps.first.showMarker(
    coords: Coords(
      details.location.position.latitude,
      details.location.position.longitude,
    ),
    title: details.address,
  );
}

So I show MapsSheet if there are more maps app installed, else I launch the only one installed.

The problem is when code is on map.showMarker the app crash with this error on console.

-canOpenURL: failed for URL: "iosamap://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "baidumap://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "yandexnavi://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "yandexmaps://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "citymapper://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "mapswithme://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "osmandmaps://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "dgis://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "qqmap://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "here-location://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "iosamap://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "baidumap://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "yandexnavi://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "yandexmaps://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "citymapper://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "mapswithme://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "osmandmaps://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "dgis://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "qqmap://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
-canOpenURL: failed for URL: "here-location://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
2
Could not cast value of type 'NSNull' (0x1f58dced8) to 'NSString' (0x1f58dce60).
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001bd8769e8 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1bd8769e8 <+8>:  b.lo   0x1bd876a04               ; <+36>
    0x1bd8769ec <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1bd8769f0 <+16>: mov    x29, sp
    0x1bd8769f4 <+20>: bl     0x1bd872670               ; cerror_nocancel
Target 0: (Runner) stopped.

My info.plist is ok because I already added this.

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>comgooglemaps</string>
  <string>baidumap</string>
  <string>iosamap</string>
  <string>waze</string>
  <string>yandexmaps</string>
  <string>yandexnavi</string>
  <string>citymapper</string>
  <string>mapswithme</string>
  <string>osmandmaps</string>
  <string>dgis</string>
  <string>qqmap</string>
  <string>here-location</string>
</array>

Let me know if I'm doing wrong.

Thank you :)

samuele-besoli-mndl commented 2 years ago

I found the problem! In some cases details.address was null so I was passing title: null and this caused the crash.