当我尝试在 Facebook 应用程序中打开链接时,Branch.io 找不到我的应用程序。它总是重定向到 App Store,即使我们的应用程序已经安装在设备上。我读过 https://blog.branch.io/deep-linking-from-facebook-in-2017/并实现了 Deepviews,但即使从那里我也无法进入该应用程序。它仍然会打开 App Store。
我认为问题出在我们的 Branch.io 配置中,但我找不到它。
注意事项:
- 我已经实现了通用链接并且它们工作正常(除了 Facebook 的这个问题)。
- 当我在 Facebook 应用程序中按下“在 Safari 中打开”时,它也能正常工作。
- 当应用程序已安装时,Deepview 始终显示“获取应用程序”而不是“打开应用程序”。
这是我创建链接的方式:
- (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"]];
这是我们的链接设置:
最佳答案
Amruta 来自 Branch.io这里:
由于 Apple 方面的限制,当用户在网络浏览器(即 Safari)上点击通用链接时,如果该链接与当前网页具有相同的域,则它不会使用通用链接来打开应用程序而是在 Safari 中打开链接。您可以阅读有关此行为的更多信息 here .
为了克服这个限制,Branch 为 Deepview 按钮后面的链接使用了不同的域,这样被访问的域就不同于当前的网页。 Deepview 按钮后面的链接使用“-alternate.app.link”格式的域。
请确保您已在权利文件中为您的应用添加 -alternate.app.link 域。您可以查看提供有关如何添加域的信息的文档 here .
关于ios - Facebook iOS App 中的 Branch.io 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45689803/