通用链接会打开我的应用程序,但不会调用application:continueUserActivity:restorationHandler [英] Universal Link opens my app but doesn't call application:continueUserActivity:restorationHandler

查看:58
本文介绍了通用链接会打开我的应用程序,但不会调用application:continueUserActivity:restorationHandler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中实现通用链接.我阅读了很多教程,并紧跟着这篇教程:如何在iOS App和设置服务器中支持通用链接吗?

I'm trying to implement Universal Links in my app. I read a lot of tutorials and followed this one to the letter: How to support Universal Links in iOS App and setup server for it?

当我单击通用链接时,我的应用程序成功打开,但未调用AppDelegate.m文件中的 application:continueUserActivity:restorationHandler ,因此无法定向到应用程序中的特定页面.

When I click a universal link my app successfully opens but application:continueUserActivity:restorationHandler in my AppDelegate.m file isn't called so I can't direct to a specific page in the app.

我的 apple-app-site-association 文件位于https上,对于路径,我放置了 ["*","/"] .我对应用程序前缀和ID进行了三重检查,确认在开发人员网站和目标中都启用了AssociatedDomains.在关联的域"部分中,我放置了我的根域以及第二个以*开头的条目.处理所有可能的子域.我正在真实设备上进行测试,而不是在模拟器上进行测试.

My apple-app-site-association file is on https and for paths I put [ "*", "/" ]. I triple-checked app prefix and ID, confirmed AssociatedDomains is enabled both on the developer website and in my target. In the Associated Domains section I put my root domain as well as a second entry prepended with *. to handle all possible subdomains. I am testing on a real device, not on the simulator.

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {
    ALog(@"Did I get here?");
}

任何人都可以提供关于我应该寻找什么的建议,以弄清楚为什么未调用 application:continueUserActivity:restorationHandler 吗?

Can anyone provide advice as to what I should be looking at to figure out why application:continueUserActivity:restorationHandler isn't being called?

更新:

我使用了Apple的验证工具 https://search.developer.apple.com/appsearch-validation-tool ,结果如下:

I used Apple's validation tool https://search.developer.apple.com/appsearch-validation-tool and it gave this result:

链接到应用程序

需要采取行动

无法提取通用链接所需的信息.了解如何实施推荐的通用链接.

Could not extract required information for Universal Links. Learn how to implement the recommended Universal Links.

没有任何具有域授权的应用程序出错用于验证深度链接双重身份验证的权利数据来自应用程序的当前发行版本.这些数据可能需要48小时才能更新.

Error no apps with domain entitlements The entitlement data used to verify deep link dual authentication is from the current released version of your app. This data may take 48 hours to update.

我不知道这是否与我的问题有关.我不会这样,因为在实际发布更新之前,我需要测试我的应用程序,以确保正确实施了通用链接.

I don't know if that has anything to do with my problem. I wouldn't think so, because I need to test my app to make sure I have Universal Links implemented properly before actually releasing the update.

推荐答案

如果应用中使用了Google Analytics(分析)或某些Firebase功能,则可能是由于方法混乱引起的.在 application(_ application:UIApplication,didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey:Any]?)中添加以下方法为我解决了这个问题.我认为禁用禁用方法也可以.

If Google Analytics or some Firebase features is used in the app, it may be caused by method swizzling. Adding the following method in application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) solves the issue for me. I think disabling method swizzling will work too.

private func swizzleSelectors() {
    
    let aClass: AnyClass! = object_getClass(UIApplication.shared.delegate)
    let originalMethod = class_getInstanceMethod(aClass, #selector(self.application(_:continue:restorationHandler:)))
    let swizzledMethod = class_getInstanceMethod(aClass, #selector(UIApplication.shared.delegate!.application(_:continue:restorationHandler:)))
    if let originalMethod = originalMethod, let swizzledMethod = swizzledMethod {
        method_exchangeImplementations(originalMethod, swizzledMethod)
    }
}

这篇关于通用链接会打开我的应用程序,但不会调用application:continueUserActivity:restorationHandler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆