How to programmatically register a custom URL sche

2019-02-12 22:51发布

Is it possible to add/remove custom URL schemes for my application while it's running? Right now the CFBundleURLSchemes property is set in Info.plist.

2条回答
够拽才男人
2楼-- · 2019-02-12 23:38

According to this discussion on Cocoa Dev the answer is no, custom URL schemes can't be registered programmatically. You must specify them in Info.plist. (but using LSRegisterURL, you can ask Launch Services to reload your application's Info.plist if you programmatically change it. But that's ugly.).

查看更多
手持菜刀,她持情操
3楼-- · 2019-02-12 23:49

Launch Services will do that. Have a look at the Launch Services Programming Guide and the Launch Services Reference for details.

(Edit: Launch Services is what you want, but the function I mentioned was for changing the default handler.)

查看更多
登录 后发表回答