我正在使用以下方法来实现深层链接。
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
当应用程序处于后台时,当我来自浏览器时,此方法未调用?
我添加了实现深度链接所需的所有步骤。
如何解决呢?
答案 0 :(得分:1)
尝试一下。
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
guard let dynamicLinks = FIRDynamicLinks.dynamicLinks() else {
return false
}
let handled = dynamicLinks.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
print(error as Any)
}
return handled
}
答案 1 :(得分:0)
#define App_Scheme @"yourbundleappschme"
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([[url scheme] isEqualToString:App_Scheme])
{
NSLog(@"Calling Application Bundle ID: %@", sourceApplication);
NSLog(@"URL scheme:%@", [url scheme]);
NSLog(@"URL query: %@", [url query]);
return YES;
}
return NO;
}
还添加了代表
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
//handle here
if ([[url scheme] isEqualToString:App_Scheme])
{
NSLog(@"URL scheme:%@", [url scheme]);
NSLog(@"URL query: %@", [url query]);
return YES;
}
return FALSE;
}
也添加 项目->目标->功能->关联域->使用添加域
应用链接:在此处域