菜鸟教程小白 发表于 2022-12-12 18:46:59

ios - 为什么会有这么多canOpenURL?


                                            <p><p>从 <a href="https://doc.open.alipay.com/doc2/detail?treeId=54&amp;articleId=103419&amp;docType=1" rel="noreferrer noopener nofollow">https://doc.open.alipay.com/doc2/detail?treeId=54&amp;articleId=103419&amp;docType=1</a> 运行 <code>AlipaySDK</code> 演示时,发生了一些奇怪的事情。 </p>

<p>从xcode中的日志输出来看,有10多条日志要说</p>

<blockquote>
<p>-canOpenURL: failed for URL: &#34;momochs://&#34; - error: &#34;This app is not allowed to query for scheme momochs</p>
</blockquote>

<p>demo中没有源码可以通过简单的搜索打印出来。并且静态库只是付款,根据我的理解不应该做这样的检查。 </p>

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

<blockquote>
<p>2016-03-02 15:58:55.998 AliSDKDemo -canOpenURL: failed for URL: &#34;momochs://&#34; - error: &#34;This app is not allowed to query for scheme momochs&#34;
2016-03-02 15:58:55.999 AliSDKDemo -canOpenURL: failed for URL: &#34;tenpay://&#34; - error: &#34;This app is not allowed to query for scheme tenpay&#34;
2016-03-02 15:58:55.999 AliSDKDemo -canOpenURL: failed for URL: &#34;com.icbc.iphoneclient://&#34; - error: &#34;This app is not allowed to query for scheme com.icbc.iphoneclient&#34;
2016-03-02 15:58:56.000 AliSDKDemo -canOpenURL: failed for URL: &#34;wx2654d9155d70a468://&#34; - error: &#34;This app is not allowed to query for scheme wx2654d9155d70a468&#34;
2016-03-02 15:58:56.000 AliSDKDemo -canOpenURL: failed for URL: &#34;meituan0000://&#34; - error: &#34;This app is not allowed to query for scheme meituan0000&#34;
2016-03-02 15:58:56.000 AliSDKDemo -canOpenURL: failed for URL: &#34;sinaweibo://&#34; - error: &#34;This app is not allowed to query for scheme sinaweibo&#34;
2016-03-02 15:58:56.001 AliSDKDemo -canOpenURL: failed for URL: &#34;dianping://&#34; - error: &#34;This app is not allowed to query for scheme dianping&#34;
2016-03-02 15:58:56.001 AliSDKDemo -canOpenURL: failed for URL: &#34;diditaxi://&#34; - error: &#34;This app is not allowed to query for scheme diditaxi&#34;
2016-03-02 15:58:56.002 AliSDKDemo -canOpenURL: failed for URL: &#34;cn.12306://&#34; - error: &#34;This app is not allowed to query for scheme cn.12306&#34;
2016-03-02 15:58:56.002 AliSDKDemo -canOpenURL: failed for URL: &#34;mtxx://&#34; - error: &#34;This app is not allowed to query for scheme mtxx&#34;
2016-03-02 15:58:56.002 AliSDKDemo -canOpenURL: failed for URL: &#34;youku://&#34; - error: &#34;This app is not allowed to query for scheme youku&#34;
2016-03-02 15:58:56.003 AliSDKDemo -canOpenURL: failed for URL: &#34;baidumap://&#34; - error: &#34;This app is not allowed to query for scheme baidumap&#34;
2016-03-02 15:58:56.003 AliSDKDemo -canOpenURL: failed for URL: &#34;iosamap://&#34; - error: &#34;This app is not allowed to query for scheme iosamap&#34;</p>
</blockquote></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><blockquote>
<p>Why so many canOpenURL ?</p>
</blockquote>

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

<p>谢天谢地,这在 iOS9 中不再允许,因为您需要提供您的应用将执行 <code>canOpenURL</code> 调用的方案列表,调用不在您的 <code>info.plist 中的 url 方案</code> 将导致您看到该日志警告</p>

<blockquote>
<p>The odd thing is I got log information as below, but can&#39;t find any
source code to print out such things.</p>
</blockquote>

<p>我看到的 SDK 不是开源的,所以你无法查看他们的代码,代码在静态库 <code>*.a</code> 文件中</p>

<blockquote>
<p>Just wonder how can they do this without source code ? Any technology to &gt;achieve this ? thanks</p>
</blockquote>

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

<p>希望这可以消除困惑,我建议保持原样,不要让他们完成这样的特技。</p>

<p>你总是可以将这些方案的列表添加到你的 <code>info.plist</code> 中,但是你必须向苹果自己解释为什么你需要打开这么多应用程序,这又是一个非常糟糕的主意,只需忽略它,您就可以开始了!</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 为什么会有这么多canOpenURL?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/35741601/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/35741601/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 为什么会有这么多canOpenURL?