Should CFBundleURLName match CFBundleIdentifier?

If I want the App App iOS to run App2 on the device, does CFBundleURLName need to map CFBundleIdentifier to CFBundleURLTypes in 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 run the β€œfooscheme:” URLs in App1. However, if I modify App1 Info.plist to enable

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

ie, CFBundleURLName! = CFBundleIdentifier, then App2 can no longer run the fooscheme: URLs in App1.

Any ideas why?

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

Thanks!

+4
source share
2 answers

No, these two properties should not coincide, I had no problems with this, just like you, I had the identifier of my application - CFBundleIdentifier - set to com.djp.myapp and the URL schemes set with CFBundleURLName set to Nothing. like.the.identifier and a CFBundleURLSchemes as abcd .

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

The only thing I can think of may create a problem for you if you run the application with the installed URL schemes and during testing you change your package identifier ( CFBundleIdentifier ), thereby actually creating 2 applications in the system. In this case, you will have a conflict of the URL scheme, and Apple will declare that there is no process to determine which application will be prioritized.

Note If more than one third-party application is registered to process the same URL scheme, there is currently no process for determining which application will provide this scheme.

Also, as far as I have tested and tested, if you have two conflicting applications, this is the first installed one that is used, and when this application is uninstalled, the second application, which is now the only application that supports a specific URL scheme, is not yet used.

This indicates that url schemes are registered in the system during installation, and to work on these schemes, a new installation of this application is required.

Learn more about URL schemes in the Apple Advances App Tricks .

+5
source

I think the reason is because you did not use the CFBundleTypeRole key, which indicates that the application is a viewer, editor, shell, or other. And this key is required in the custom URL scheme.

Note. osx does not launch your application if you install it on None.

You can get information from here Apple Developer Document

+1
source

Source: https://habr.com/ru/post/1441671/


All Articles