App Links on iOS

Your app can post stories to news feed. When people click on those stories, Facebook can send people to either your app or your app's App Store page. This drives traffic and app installs. You can implement this behavior using App Links.

When someone taps on one of the links shared through your app or on the story attribution (name of your app) in one of the Open Graph stories shared through your app, the link content appears in a webview with a menu item Open in {app name}. Clicking on that menu item will either open your app or, if the your app is not installed on the device, open your app's App Store page. If your app is mobile-only and has no web content, when someone clicks the shared link they either open your app, if it's installed, or go to your app's App Store page (if your app isn't installed). The image below shows this flow:

Beginning with iOS v10, deferred deep linking is not supported on devices where the limit ad tracking setting is enabled. On those devices your app can only open the start screen for your app after someone installed your app.

In the following sections we will explain how to handle incoming links once you've set up your App Links.

Handling incoming links

When someone taps a link posted from your app or taps the app attribution in an Open Graph story posted from your app in Facebook for iOS, they may be presented with the option to open your content in your iOS app. Alternatively, they may be immediately directed to your app. If your app is mobile only, set should_fallback=false so that if people don't have your app installed, they will be taken to the App Store to download your app. The iOS app link for your content will be sent to your app. To ensure an engaging user experience, you should process the incoming link when your app is activated and direct the person to the object featured in the story they're coming from.

The link your app will receive will look like this:


Where url is the incoming URL based on a custom scheme that you've defined for your app. You'll also receive an al_applink_data query parameter with JSON_ENCODED_DATA content that looks something like this:

    "target_url": "",
    "extras": {
        "fb_app_id": [YOUR_FACEBOOK_APP_ID],
        "fb_access_token": "[ACCESS_TOKEN']",
        "fb_expires_in": "3600"
    "referer_app_link": {
        "url": "[FACEBOOK_APP_BACK_LINK]",
        "app_name": "Facebook"

Where fb_access_token and fb_expires_in are only available if the person has authenticated with Facebook in your app.

You can then override the application:openURL:sourceApplication:annotation: method in your app delegate implementation file to customize how your app handles these incoming urls.

In the code sample below, we're simply displaying an alert to the person, but you should direct people through the appropriate flow for your app:

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    BFURL *parsedUrl = [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];
    if ([parsedUrl appLinkData]) {
        // this is an applink url, handle it here
        NSURL *targetUrl = [parsedUrl targetURL];
        [[[UIAlertView alloc] initWithTitle:@"Received link:"
                                    message:[targetUrl absoluteString]
                          otherButtonTitles:nil] show];

Adding back navigation

When your app is launched as a result of an app link, you should provide people a way to navigate back to the original app. In our scenario, people should be able to get back to the Facebook for iOS app. The App Links standard describes the expected back navigation flow. When your app is launched, a referer_app_link parameter is provided as part of the incoming URL. The launching app's name is also provided. You can use these two pieces of data to construct the back navigation and present a view that the person can interact with.

First store the referer info when the app link is processed:

// AppDelegate.h
@property (strong, nonatomic) NSDictionary *refererAppLink;

// AppDelegate.m
- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    BFURL *parsedUrl = [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];
    NSDictionary *appLinkData = [parsedUrl appLinkData];
    if (applinkData) {
        // Save the referer link info
        self.refererAppLink = applinkData[@"referer_app_link"];

Then you use this info to set up a way for the person to get back to Facebook for iOS. In the example below, a UIView is set up if a referer link is found in the app delegate. This view is set up with a UITapGestureRecognizer to process taps from the person and launch the referer link if it can be opened:

// ShareViewController.m

@interface ShareViewController () <UIGestureRecognizerDelegate>
@property (strong, nonatomic) NSDictionary *backLinkInfo;
@property (weak, nonatomic) UIView *backView;
@property (weak, nonatomic) UILabel *backLinkLabel;

@implementation ShareViewController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    if (delegate.refererAppLink) {
        self.backLinkInfo = delegate.refererAppLink;
        [self _showBackLink];
    delegate.refererAppLink = nil;

- (void) _showBackLink {
    if (nil == self.backLinkView) {
        // Set up the view
        UIView *backLinkView = [[UIView alloc] initWithFrame:
                                CGRectMake(0, 30, 320, 40)];
        backLinkView.backgroundColor = [UIColor darkGrayColor];
        UILabel *backLinkLabel = [[UILabel alloc] initWithFrame:
                                  CGRectMake(2, 2, 316, 36)];
        backLinkLabel.textColor = [UIColor whiteColor];
        backLinkLabel.textAlignment = NSTextAlignmentCenter;
        backLinkLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:14.0f];
        [backLinkView addSubview:backLinkLabel];
        self.backLinkLabel = backLinkLabel;
        [self.view addSubview:backLinkView];
        self.backLinkView = backLinkView;
    // Show the view
    self.backLinkView.hidden = NO;
    // Set up the back link label display
    self.backLinkLabel.text = [NSString
                               stringWithFormat:@"Touch to return to %@", self.backLinkInfo[@"app_name"]];
    // Set up so the view can be clicked
    UITapGestureRecognizer *tapGestureRecognizer =
    [[UITapGestureRecognizer alloc] initWithTarget:self
    tapGestureRecognizer.numberOfTapsRequired = 1;
    [self.backLinkView addGestureRecognizer:tapGestureRecognizer];
    tapGestureRecognizer.delegate = self;

- (void)_returnToLaunchingApp:(id)sender {
    // Open the app corresponding to the back link
    NSURL *backLinkURL = [NSURL URLWithString:self.backLinkInfo[@"url"]];
    if ([[UIApplication sharedApplication] canOpenURL:backLinkURL]) {
        [[UIApplication sharedApplication] openURL:backLinkURL];
    self.backLinkView.hidden = YES;