How to programmatically register a custom URL scheme?

半世苍凉 提交于 2019-12-29 06:49:11

问题


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.)



来源:https://stackoverflow.com/questions/5463998/how-to-programmatically-register-a-custom-url-scheme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!