ios9万能链接不起作用

时间:2021-09-18 15:20:47

I tried to implement universal links in my application, but it's not working. I uploaded the apple-app-site-association file to my server, i can access it. (MIME type: application/json) Here is the content of the apple-app-site-association file:

我尝试在我的应用程序中实现通用链接,但它不起作用。我上传了苹果应用程序站点关联文件到我的服务器,我可以访问它。(MIME类型:application/json)这里是苹果应用程序-站点关联文件的内容:

{
"applinks": {
    "apps": [],
    "details": [
        {
            "appID": "L7LAMSGWAK.com.example.app",
            "paths": [
                "*"
            ]
        }        ]
}
}

I turned on the Associated domains in my application, and i added these domains: applinks:example.com

我打开了应用程序中的相关域,并添加了这些域:applinks:example.com

applinks:demo.example.com

applinks:demo.example.com

(i uploaded the apple-app-site-association file to the demo.example.com domain too)

(我也将苹果-app-site-association文件上传到demo.example.com域)

In the AppDelegate.m file i wrote this:

在AppDelegate。m文件我写了:

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
NSURL* openedUrl = userActivity.webpageURL;
NSString* urlString = [openedUrl.absoluteString lowercaseString];
return YES;
}

And i set a breakpoint into this method to check if its called, but its never called. If i click on for example this link: https://demo.example.com/asd its just open the safari, but i never see the banner to open the link in my application. I really dont know whats wrong.

我在这个方法中设置了一个断点来检查它是否被调用,但是它从未被调用。例如,如果我点击这个链接:https://demo.example.com/asd它只是打开safari,但是我从来没有在我的应用程序中看到打开链接的横幅。我真的不知道出了什么事。

2 个解决方案

#1


2  

Try to delete and reinstall the app. iOS processes associated domain details and attempts to read the apple-app-site-association file at app install. It worth trying it with a real device (instead of the Simulator) and check device logs (Xcode > Window > Devices and select your device). If you see anything like ### Rejecting URL 'https://demo.example.com/apple-app-site-association' for auth method 'NSURLAuthenticationMethodServerTrust': -6754/0xFFFFE59E kAuthenticationErr, then probably your site's certificate is not good enough for iOS or there is some other issue with downloading your association file.

尝试删除并重新安装app. iOS处理相关的域细节,并尝试在app安装时读取苹果app-site-association文件。它值得用一个真正的设备(而不是模拟器)来尝试,并检查设备日志(Xcode >窗口>设备并选择您的设备)。如果您看到类似### ### #拒绝URL 'https://demo.example.com/apple-app-site-association'的auth方法'NSURLAuthenticationMethodServerTrust: -6754/0xFFFFE59E kAuthenticationErr,那么您的站点证书对于iOS可能不够好,或者下载您的关联文件还有其他问题。

#2


1  

Kind of a late answer, but I had the same problem when I was trying to implement universal links. The solution for me was to test using a real device.

有点晚了,但是我在尝试实现通用链接时遇到了同样的问题。我的解决方案是用一个真正的设备进行测试。

The Apple documentation lists that it's possible to test on a simulator, but with my own experience, it hasn't been possible.

苹果的文档列出了在模拟器上进行测试是可能的,但根据我自己的经验,这是不可能的。

You can test universal links in Simulator or on a device. Source - Apple

您可以在模拟器或设备上测试通用链接。源——苹果

I also tried using Branch.io and they state that it's not possible to test using a simulator.

我也尝试过使用Branch。io和他们说用模拟器测试是不可能的。

You should also verify that you're using a device that's running iOS >= 9.2

您还应该验证您正在使用的设备正在运行iOS >= 9.2

#1


2  

Try to delete and reinstall the app. iOS processes associated domain details and attempts to read the apple-app-site-association file at app install. It worth trying it with a real device (instead of the Simulator) and check device logs (Xcode > Window > Devices and select your device). If you see anything like ### Rejecting URL 'https://demo.example.com/apple-app-site-association' for auth method 'NSURLAuthenticationMethodServerTrust': -6754/0xFFFFE59E kAuthenticationErr, then probably your site's certificate is not good enough for iOS or there is some other issue with downloading your association file.

尝试删除并重新安装app. iOS处理相关的域细节,并尝试在app安装时读取苹果app-site-association文件。它值得用一个真正的设备(而不是模拟器)来尝试,并检查设备日志(Xcode >窗口>设备并选择您的设备)。如果您看到类似### ### #拒绝URL 'https://demo.example.com/apple-app-site-association'的auth方法'NSURLAuthenticationMethodServerTrust: -6754/0xFFFFE59E kAuthenticationErr,那么您的站点证书对于iOS可能不够好,或者下载您的关联文件还有其他问题。

#2


1  

Kind of a late answer, but I had the same problem when I was trying to implement universal links. The solution for me was to test using a real device.

有点晚了,但是我在尝试实现通用链接时遇到了同样的问题。我的解决方案是用一个真正的设备进行测试。

The Apple documentation lists that it's possible to test on a simulator, but with my own experience, it hasn't been possible.

苹果的文档列出了在模拟器上进行测试是可能的,但根据我自己的经验,这是不可能的。

You can test universal links in Simulator or on a device. Source - Apple

您可以在模拟器或设备上测试通用链接。源——苹果

I also tried using Branch.io and they state that it's not possible to test using a simulator.

我也尝试过使用Branch。io和他们说用模拟器测试是不可能的。

You should also verify that you're using a device that's running iOS >= 9.2

您还应该验证您正在使用的设备正在运行iOS >= 9.2