shamnad
shamnad

Reputation: 338

Deep-linking Xamarin iOS

I need to add deep linking feature to my app with Xamarin iOS. My info.plist looks like this:

<key>CFBundleURLTypes</key>
<array>
<dict>
  <key>CFBundleURLSchemes</key>
  <array>
    <string>domine.somthing/index.html?UV</string>
  </array>
  <key>CFBundleURLTypes</key>
  <string>com.domine.somthing/index.html?UV</string>  
</dict>

I seems not working due to "/" char in the URL. How am I supposed to write CFBundleURLTypes and CFBundleURLSchemes URL values in order to make it work?

Upvotes: 2

Views: 2756

Answers (1)

Nerkyator
Nerkyator

Reputation: 3976

Deep links can returns users directly to your application. After adding URI support to your application like you did, just clicking on a URL consisting of a scheme name for your application will launch your app, but it seems you are filling CFBundleURLSchemes and CFBundleURLTypeswith with wrong values.

CFBundleURLName - Usually, this corresponds to the bundle ID of your application. Please see Apple's Development doc for more informations.

CFBundleURLSchemes - Array of strings containing URL scheme names, usually at least your application's name (without spaces). Pay attentiont to ensure these values are unique to your application.

Look at this sample:

<key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLName</key>
      <string>com.yourcompany.yourapp</string>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>appname</string>
      </array>
    </dict>
  </array>

Now clicking on a URL consisting of appname:// on the device will launch your app.

If you want to send a user to a specific part of your application, you need to add arguments to this URL, making a deep link. Here is a sample with a path and query:

appname://custompath?customquery=customvalue

When a user clicks a URL containing your scheme (appname://), your app's delegate is called and specifically the method OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)where you can handle schemas an execute correct app routing based on schema arguments (if provided).

Upvotes: 8

Related Questions