Igor Savelev
Igor Savelev

Reputation: 23

Branch.io links in Facebook iOS App

Branch.io can't find my app, when I try to open link in Facebook App. It always redirects to the App Store, even when our app is already installed on the device. I've read https://blog.branch.io/deep-linking-from-facebook-in-2017/ and implemented Deepviews, but even from there I can't get into the app. It still opens App Store.

I assume that the problem is in our Branch.io configuration, but I can't find it.

Notes:

  1. I've implemented Universal Links and they work fine (except this problem with Facebook).
  2. When I press on "Open in Safari" in the Facebook app, it also works fine.
  3. Deepview always shows "Get the app" instead of "Open app", when the app is already installed.

This is how I create the link:

- (BranchUniversalObject *)generateBranchObjectFor:(MBMediaObject *)object {
    NSArray<NSString *> *pathComponents = [object.shareLink pathComponents];
    NSString *uid = [[pathComponents subarrayWithRange:NSMakeRange(pathComponents.count-2, 2)] componentsJoinedByString:@"/"];
    BranchUniversalObject *branchObject = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:uid];
    branchObject.title = object.name;
    branchObject.imageUrl = object.imageURL.absoluteString;
    if ([object isKindOfClass:MBSong.class]) {
        branchObject.contentDescription = ((MBSong *)object).artistName;
    } else if ([object isKindOfClass:MBAlbum.class]) {
        branchObject.contentDescription = ((MBAlbum *)object).artist.name;
    }
    return branchObject;
}

- (BranchLinkProperties *)generateBranchLinkPropertiesForObject:(MBMediaObject *)object channel:(NSString *)channel {
    BranchLinkProperties *properties = [BranchLinkProperties new];
    properties.feature = @"sharing";
    properties.channel = channel;
    [properties addControlParam:@"$deeplink_path" withValue:[[object.shareLink stringByReplacingOccurrencesOfString:@"http://" withString:@""] stringByReplacingOccurrencesOfString:@"https://" withString:@""]];
    return properties;
}

NSString *shortURLString = [[self generateBranchObjectFor:object] getShortUrlWithLinkProperties:[self generateBranchLinkPropertiesForObject:object channel:@"twitter"]];

And this is our link settings:

Upvotes: 0

Views: 553

Answers (1)

Amruta Deshmukh
Amruta Deshmukh

Reputation: 1045

Amruta from Branch.io here:

Due to a restriction on Apple's side, when the user taps on a Universal link on the web browser (i.e. Safari), if the link has the same domain as the current web page it does not use Universal linking to open the app but instead opens the link in Safari. You can read more about this behavior here.

To overcome this restriction, Branch uses a different domain for the link behind the Deepview button, so that the domain being visited is different from the current web page. The link behind the Deepview button uses the domain of the format '-alternate.app.link'.

Please ensure that you have added the -alternate.app.link domain for your app in the entitlements file. You can check the documentation providing information on how to add the domains here.

Upvotes: 3

Related Questions