ios – CFBundleURLName必须与CFBundleIdentifier匹配吗?

ios – CFBundleURLName必须与CFBundleIdentifier匹配吗?,第1张

概述如果我希望iOS App App1在设备上启动App2,那么CFBundleURLName是否需要匹配Info.plist中CFBundleURLTypes中的CFBundleIdentifier? 例如,如果我在App1中 <key>CFBundleIdentifier</key><string>com.foo.App1</string>...<key>CFBundleURLTypes</ 如果我希望iOS App App1在设备上启动App2,那么CFBundleURLname是否需要匹配Info.pList中CFBundleURLTypes中的CFBundleIDentifIEr?

例如,如果我在App1中

<key>CFBundleIDentifIEr</key><string>com.foo.App1</string>...<key>CFBundleURLTypes</key><array><key>CFBundleURLTypes</key><array>    <dict>        <key>CFBundleURLSchemes</key>        <array>            <string>fooscheme</string>        </array>        <key>CFBundleURLname</key>        <string>com.foo.App1</string>    </dict></array>

在上面的例子中,App2可以在App1中启动“fooscheme:”url.但是,如果我将App1的Info.pList更改为包含

<key>CFBundleURLTypes</key><array>    <dict>        <key>CFBundleURLSchemes</key>        <array>            <string>fooscheme</string>        </array>        <key>CFBundleURLname</key>        <string>com.foo.xyz</string>    </dict></array>

即,CFBundleURLname!= CFBundleIDentifIEr,然后App2再也无法在App1中启动“fooscheme:”url.

有什么想法吗?

我没有看到CFBundleIDentifIEr必须与CFBundleURLname匹配的任何Apple文档,但实际情况似乎如此.或者我错过了什么?

谢谢!

解决方法 不,这两个属性不需要匹配,我没有像你那样有问题,我有我的应用程序标识符 – CFBundleIDentifIEr – 设置为com.djp.myapp和设置为CFBundleURLname设置为空的url方案. like.the.IDentifIEr和CFBundleURLSchemes设置为abcd.

我可以通过调用:abcd://打开这个应用程序

我能想到的一件事可能是给你带来一个问题,如果你运行你的应用程序设置了url方案,并且在测试期间你改变了你的包标识符(CFBundleIDentifIEr),从而实际上导致系统中存在2个应用程序.
在这种情况下,您将遇到网址方案冲突,Apple声明没有任何流程可以确定哪个应用优先.

Note: If more than one third-party app registers to handle the same
URL scheme,there is currently no process for determining which app
will be given that scheme.

此外,据我测试和经验,如果你有两个冲突的应用程序,它似乎是第一个安装使用,并删除此应用程序时,第二个应用程序,现在是唯一支持特定网址方案的应用程序仍未使用.

这表明url方案在安装时已在系统中注册,并且需要新安装此应用程序才能使其按预期方式处理这些方案.

有关URL Schemes的更多信息,请查看Apple Advances App Tricks文档.

总结

以上是内存溢出为你收集整理的ios – CFBundleURLName必须与CFBundleIdentifier匹配吗?全部内容,希望文章能够帮你解决ios – CFBundleURLName必须与CFBundleIdentifier匹配吗?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1075693.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存