为什么有这么多canOpenURL?

Why so many canOpenURL?

当 运行 AlipaySDK 来自 https://doc.open.alipay.com/doc2/detail?treeId=54&articleId=103419&docType=1 的演示时,发生了一些奇怪的事情。

从xcode中的日志输出来看,有10多条日志可以说

-canOpenURL: failed for URL: "momochs://" - error: "This app is not allowed to query for scheme momochs

demo中没有源码可以打印出这样的东西,简单搜索一下。而静态库只是支付,根据我的理解不应该做这样的检查。

这里的问题是弄清楚为什么会发生这种情况,或者演示或其他设置有问题吗?

2016-03-02 15:58:55.998 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "momochs://" - error: "This app is not allowed to query for scheme momochs" 2016-03-02 15:58:55.999 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "tenpay://" - error: "This app is not allowed to query for scheme tenpay" 2016-03-02 15:58:55.999 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "com.icbc.iphoneclient://" - error: "This app is not allowed to query for scheme com.icbc.iphoneclient" 2016-03-02 15:58:56.000 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "wx2654d9155d70a468://" - error: "This app is not allowed to query for scheme wx2654d9155d70a468" 2016-03-02 15:58:56.000 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "meituan0000://" - error: "This app is not allowed to query for scheme meituan0000" 2016-03-02 15:58:56.000 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "sinaweibo://" - error: "This app is not allowed to query for scheme sinaweibo" 2016-03-02 15:58:56.001 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "dianping://" - error: "This app is not allowed to query for scheme dianping" 2016-03-02 15:58:56.001 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "diditaxi://" - error: "This app is not allowed to query for scheme diditaxi" 2016-03-02 15:58:56.002 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "cn.12306://" - error: "This app is not allowed to query for scheme cn.12306" 2016-03-02 15:58:56.002 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "mtxx://" - error: "This app is not allowed to query for scheme mtxx" 2016-03-02 15:58:56.002 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "youku://" - error: "This app is not allowed to query for scheme youku" 2016-03-02 15:58:56.003 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "baidumap://" - error: "This app is not allowed to query for scheme baidumap" 2016-03-02 15:58:56.003 AliSDKDemo[4491:1610409] -canOpenURL: failed for URL: "iosamap://" - error: "This app is not allowed to query for scheme iosamap"

Why so many canOpenURL ?

因为他们想知道安装了哪些应用程序,直到 iOS8 这是知道您安装了哪些应用程序的丑陋技巧,他们基本上有一个他们想知道的应用程序方案列表,所以他们将为每个应用方案连续 canOpenURL 调用,然后收集数据并将其发送回他们的服务器以用于他们需要的任何目的。

谢天谢地,这在 iOS9 中不再允许,因为您需要提供您的应用程序将执行 canOpenURL 调用的方案列表,调用不在其中的 url 方案您的 info.plist 将导致您看到

的日志警告

The odd thing is I got log information as below, but can't find any source code to print out such things.

据我所知,SDK 并未开源,因此您无法查看其代码,代码在静态库 *.a 文件中

Just wonder how can they do this without source code ? Any technology to >achieve this ? thanks

没什么特别的,如果你编写一个项目并将其构建为静态库,你将在 .a 文件中获得编译后的源代码,你可以将其导入其他项目并在那里使用,只要你有正确的头文件,支付宝就是这样做的

希望这能消除困惑,我建议保持原样,不要让他们那样表演特技。

您可以随时将这些方案的列表添加到您的 info.plist,但是您必须自己向 apple 解释为什么您需要打开这么多应用程序,同样,非常糟糕的主意,只需忽略它,你很高兴去!