Mosin Pathan
Mosin Pathan

Reputation: 11

How to open another application from my Xamarin forms iOS app and get response back.?

I am trying to open another application(BHIM/Paytm) through my application in Xamarin.Forms.I am able to open it in Xamarin.Forms android and getting response also for same using Intent.Can anyone help me with open application in Xamarin.Forms iOS and retrieving response from same app.Thank You.

Upvotes: 0

Views: 377

Answers (1)

Junior Jiang
Junior Jiang

Reputation: 12721

First,make sure that adding the below key in the info.plist in the application you 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>

Second 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")); 
}

If you want back to front app , using this same way.And if have data shared between app, be dealed with follow method.

public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
{
     return base.OpenUrl(application, url, sourceApplication, annotation);
}

Upvotes: 1

Related Questions