Is it possible to register a custom Url scheme or Protocol, like myapp:123, with MonoTouch? I'd like my MonoTouch app to launch when the user clicks this link in a web page, mail or calendar description, and pick upp the url "parameters", in this case "123".
In short I want the same functionality as for the Spotify app in iPhone with its spotify:track:123123 Can it be done?
Nearly all iOS apps assign themselves one or more URL scheme names. Many also code in various path, parameter, anchor, query, and fragment components for specific requests (sometimes called “deep links”).
URL schema is used as an identifier in launching applications and performing a set of commands in iOS devices. The schema name of a URL is the first part of a URL. (e.g. schemaname:// ). For web pages, the schemas are usually http or https.
Find app link via App Store on iOS devices Step 1: Go to the Apple App Store on your iOS device. Step 2: Search for your app and go to the app page. Step 3: Tap the Share Sheet button on the top right of the screen, then choose Copy Link.
Yes it is and here's what you need to do.
Add in Info.Plist the following somewhere within the dict tags:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.companyname.com.receiver</string>
<key>CFBundleURLSchemes</key>
<array>
<string>myapp</string>
</array>
</dict>
</array>
Then in AppDelegate.cs override the HandleOpenURL
method:
public override bool HandleOpenURL (UIApplication application, NSUrl url)
{
if (url == null) {
return false;
}
var uri = new Uri(url.ToString()); // I prefer working with the Uri class.
// Your logic here
return true;
}
Yes, I've done it in a couple of my MonoTouch applications. It is actually required when you use the Facebook SDK for logging into your app.
In general, follow the same instructions you would for a regular Objective-C app: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html (look under "Communicating with other apps")
In your AppDelegate
there is a HandleOpenURL
method to override. Beyond that there are just some settings in your Info.plist to change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With