Akash Amin
Akash Amin

Reputation: 2761

How to use URL schemes to open another Application from my Application in Xamarin iOS

What I want is, to open another application from my Xamarin Forms application in iOS. I read about URL schemes in iOS, but how to implement that in Xamarin Applications. I am using dependency service to call native functions. I have done that in Android and works perfectly.

I found a link https://riccardo-moschetti.org/2014/10/03/opening-a-mobile-app-from-a-link-the-xamarin-way-url-schemas/. But it uses Xamarin Studio and i am using Visual Studio and VS2015 does not have this option.

Anyone has a better solution for this?

Upvotes: 1

Views: 6467

Answers (1)

Akash Amin
Akash Amin

Reputation: 2761

I have solved it by adding the below key in the info.plist in the application I want to open.

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.example.ios</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>testscheme</string>
        </array>
    </dict>
</array>

And then using the below code to open the application

if(!UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("testscheme://com.example.ios")))
{
//Use the code below to go to itunes if application not found.
UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("itms://itunes.apple.com/in/app/appname/appid")); 
}

Upvotes: 1

Related Questions