当应用程序处于后台模式(已安装并启动一次)时,单击动态链接会调用continueUserActivity方法。
但是,当应用尚未启动(或未安装)时,应用似乎无法检测到动态链接。 application:openURL:从不调用options,application:userActivity:recoverHandler仅在应用程序已启动时调用。 我在applicationDidFinishLaunchWithOptions中遗漏了什么吗?
提前感谢您提供的所有帮助!
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//custom scheme is set to my bundleID as recommended
[FIROptions defaultOptions].deepLinkURLScheme = MY_CUSTOM_SCHEME;
[FIRApp configure]
return YES
}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
FIRDynamicLink *dynamicLink = [[FIRDynamicLinks dynamicLinks] dynamicLinkFromCustomSchemeURL:url];
if (dynamicLink) {
if (dynamicLink.url) {
// Handle the deep link. For example, show the deep-linked content,
// apply a promotional offer to the user's account or show customized onboarding view.
// ...
NSLog(@"opened with dynamic link");
} else {
// Dynamic link has empty deep link. This situation will happens if
// Firebase Dynamic Links iOS SDK tried to retrieve pending dynamic link,
// but pending link is not available for this device/App combination.
// At this point you may display default onboarding view.
NSLog(@"not opened with dynamic link");
}
return YES;
}
return NO;
}
- (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *))restorationHandler {
NSLog(@"continueUserActivity called");
BOOL handled = [[FIRDynamicLinks dynamicLinks] handleUniversalLink:userActivity.webpageURL
completion:^(FIRDynamicLink * _Nullable dynamicLink,
NSError * _Nullable error) {
NSLog(@"continueUserActivity called");
if (error) {
NSLog(@"dynamic link error: %@", error.localizedDescription);
}
else {
NSLog(@"dynamic link called: %@", dynamicLink.url);
}
}];
return handled;
}
答案 0 :(得分:1)
您使用的是哪个版本的Firebase动态链接SDK?确保您已更新到最新版本。还要运行方法[FIRDynamicLinks performDiagnosticsWithCompletion:nil];
并检查输出是否有任何错误。
你在哪个应用程序中点击动态链接?您是否继续点按AppPreview页面中的OPEN按钮?