iOS Facebook Deep Linking

facebook_iconDeep links are used to take users directly to the content they are interested in inside your application. In Facebook Ads you’re showing specific content that users are interested in which leads to app install. Using deep links you can take the users straight to that content upon installation. Without deep links users are left on the home screen once they run the application and they have to search for that specific content themselves.

To add deep links support to your app, first you need to create and configure your Facebook application (if you don’t already have one).

Go to your Facebook app Dashboard > Settings (Basic) and select Add Platform (choose iOS). Fill in your Bundle ID, URL Scheme and App Store IDs. Just a side note, if you do not have App store ID for that particular app, you can use any App Store ID for testing purposes. Facebook will open App Store for that application, but the deferred deep links will still work.

fb_app_settings

Add the values below to your Info.plist. Update the values in curly braces.

Download the Facebook iOS SDK and add the frameworks (drag&drop) to your project. If you need additional support check out Facebook SDK Getting Started.

Import FBSDKCoreKit in your AppDelegate and add the following:

Using the fetchDeferredAppLink closure, if the deferred deep link has been fetched (just after the install) you’ll be able to navigate directly to the content the user is looking for, creating a seamless experience from taping the Facebook Ad to navigating to that content in your app.

The  open url delegate method is for use cases where your app is already installed. Users will be redirected to your app and content will be displayed using the provided URL.

To test your deep links you can use App Ads Helper. Choose your app, scroll to the bottom of the page and click on Test Deep Link. Input your deep link into the field and select “Send Notification” and “Send Deferred”. Delete the app from the device to test the first install. Open the Facebook app and check notifications. You should see the deep link notification there. Tapping the notification will lead to the App Store. At that point run the app from XCode to test deferred deep link. It will be valid only once, to test more you should send multiple deferred deep links. If you want to test the case where your app is already installed just uncheck the “Send Deferred” and repeat the process.

test_deep_link

For testing deep links this is all that is needed but, in addition to deep links, you’ll probably want to track app installs from Facebook Ads. For that purpose you need to associate advertising accounts with your app using the app dashboard. In your Facebook app’s dashboard, go to Settings  (Advanced) and add account IDs to the “Authorized Ad Account IDs” input field.

Check out the sample app at my GitHub repo. In Info.plist just replace curly braces with appropriate data and you’re good to go.

If you liked this blog post I’d appreciate if you followed me on Twitter

Related Post

Remember to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInEmail this to someone

3 thoughts on “iOS Facebook Deep Linking

  1. There is no mention about which device the notification will be sent too, as my app is already in the appstore, and I am implementing deep linking now, I don’t know if the push notification will be sent to all of the devices!!

    1. Prior to sending the notification I was fearful, if all of my current users may not receive the notification. But then I realised the text says ‘Facebook’ app. So notification will be sent to Facebook app. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *