Home > Blockchain >  Apple Maps Link Opens in Safari before native app
Apple Maps Link Opens in Safari before native app

Time:05-23

I am running into a little issue in which Safari is opening before directly launching into the native Apple Maps app in Xamarin. I followed this tutorial somewhat: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/map/native-map-app

        var locationUrl = Device.RuntimePlatform == Device.iOS ?
            $"http://maps.apple.com/?q={address}" :
            $"http://maps.google.com/?q={address}";

        var uri = new Uri( locationUrl ).AbsoluteUri;

        try
        {
            await Launcher.OpenAsync( uri );
        }

        catch
        {
            await AppState.Current.NavigateToExternalBrowserAsync( uri );
        }

This works perfectly in Android and launches directly into the native application. I followed this apple maps scheme: https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html. Any help would be much appreciated!

CodePudding user response:

I believe this is Apple's intention. From developer.apple.com:

Map links are specified as regular http links and are opened either in Safari or the Maps app on the target platform.

If it briefly opens in Safari it is most likely recognizing the URI inside the browser and porting it to the app (like how you can "Open in App" with some websites, except this is automatic).

CodePudding user response:

According to Apple document: Unlike some schemes, map URLs do not start with a “maps” scheme identifier. Instead, map links are specified as regular http links and are opened either in Safari or the Maps app on the target platform.

  • Related