Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Must CFBundleURLName match CFBundleIdentifier?

Tags:

ios

iphone

ipad

If I want iOS App App1 to launch App2 on a device, then does the CFBundleURLName need to match the CFBundleIdentifier in the CFBundleURLTypes in the Info.plist?

For example, if I have in 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>

In the above case, App2 can launch "fooscheme:" urls in App1. However, if I change App1's Info.plist to include

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

i.e., a CFBundleURLName != CFBundleIdentifier, then App2 can no longer launch "fooscheme:" urls in App1.

Any ideas why?

I don't see any Apple documentation that CFBundleIdentifier must match CFBundleURLName, but this seems to be the case in practice. Or am I missing something?

Thanks!

like image 254
Joel Avatar asked Oct 23 '12 22:10

Joel


2 Answers

No, these two properties do not need to match, I didn't have issues with this as you did, I had my app identifier - CFBundleIdentifier - set to com.djp.myapp and the url schemes set up with CFBundleURLName set to nothing.like.the.identifier and a CFBundleURLSchemes set as abcd.

I could open this app by calling: abcd://

The one thing I could think may be posing a problem for you is if you ran your app with the url schemes set up, and during testing you changed your bundle identifier (CFBundleIdentifier), thus actually causing 2 apps to exist in the system. In this case you would have a url scheme conflict and Apple state that there isn't any process for determining which app will take priority.

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.

Also as far as I've tested and experienced, if you have 2 conflicting apps, it appears to be the first one installed which is used, and when this app is removed the second app which is now the only app supporting the specific url scheme is still not used.

This suggests url schemes are registered with the system at time of installation, and a new installation of this app is required to get it working on those schemes as expected.

For more info about URL Schemes check out the Apple Advances App Tricks document.

like image 106
Daniel Avatar answered Sep 19 '22 01:09

Daniel


I think the reason was you didn't special the CFBundleTypeRole key which indicate you application is a viewer,editor,shell or other. And this key is required in custom URL scheme.

Note:osx will not launch your application when you set it to None.

You could get information from here Apple Developer Document

like image 40
YuDenzel Avatar answered Sep 21 '22 01:09

YuDenzel