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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.).
回答2:
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.)