我为动态链接挣扎了好几天。请感谢任何帮助。 我集成了Firebase动态链接,如果我将链接粘贴到Chrome网址中,然后按Enter,它可以打开事件触发并传递了网址的应用 但是如果我单击预览页面上的“打开”按钮,则无论是否安装了该应用程序,它始终会打开App Store 有什么想法吗?
我浏览了网络上的所有帖子,但没有好运。
"react-native": "^0.59.5"
"react-native-firebase": "^5.3.1"
pod 'Firebase/Core', '~> 5.20.1'
pod 'Firebase/DynamicLinks', '~> 5.20.1'
在Firebase控制台上的域:https://links.umrgo.com/links
捆绑ID:com.umrgo.www.umr-app-ios
URL Types identifier: links.umrgo.com
URL Types identifier: com.umrgo.www.umr-app-ios
capabilities: applinks:links.umrgo.com
发布版本
我还用字符串数组添加FirebaseDynamicLinksCustomDomains https://links.umrgo.com
我的一些代码如下。
[FIROptions defaultOptions].deepLinkURLScheme = @"com.umrgo.www.umr-app-ios";
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
options:(NSDictionary<NSString*, id> *)options
{
BOOL handled = [[RNFirebaseLinks instance]
application:application
openURL:url
options:options
] || [RCTLinkingManager
application:application
openURL:url
options:options
];
return handled;
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler {
BOOL handled = [[RNFirebaseLinks instance]
application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler
] || [RCTLinkingManager
application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler
];
return handled;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
BOOL handled = [RCTLinkingManager
application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
return handled;
}
const link = new firebase.links.DynamicLink(`https://www.umrgo.com/publish/${publishId}?publishType=${publishType}&publishId=${publishId}&otherUserUnionId=${currentUserUnionId}&conversationId=${conversationId}`,
'links.umrgo.com/links').android.setPackageName(conf.GooglePackageName).ios.setBundleId(conf.AppleBundleId).ios.setAppStoreId(conf.AppleAppID);
firebase.links()
.createShortDynamicLink(link, 'UNGUESSABLE')
.then((url) => {
var payload = {
key: createLinkUniqueKey(conversationId, publishId, currentUserUnionId, publishType),
url: url,
publish_id: publishId,
target_user_unionid: currentUserUnionId,
conversation_id: conversationId,
publish_type: publishType
}
axios.post(getApiEndpoint(conf.UMRApiUrls.createDynamicLinkRemote), payload, {
headers: getAuthHeader()
}).then(response => {
console(response)
})
});
下面是一些快照:
enter link in browser and press enter
答案 0 :(得分:0)
您提到将链接粘贴到浏览器中。如果您在 Safari 中执行此操作,它会故意不直接转到您的应用程序,因为设备会假设您的意图是打开网页。如果您点击链接,它的行为可能会有所不同。 Chrome 可能也在遵循同样的想法。
这个答案提供了一些很好的测试步骤来确保它正常工作:https://stackoverflow.com/a/44817701/2612222