[英]Making App default handler on OSX 10.10 with sandbox enabled
I wasn't able to find anything online about this, but LSSetDefaultHandlerForURLScheme will return -54 when the sandbox is enabled. 我无法在网上找到任何关于此的信息,但是当启用沙箱时,LSSetDefaultHandlerForURLScheme将返回-54。 I'm not sure what entitlement needs to be turned on for this to work as it does without the sandbox on.
我不确定需要启用什么权利才能使用它,因为它没有启用沙箱。
To see this in effect, create a new project with this in the appdelegate: 要查看此效果,请在appdelegate中使用此项创建一个新项目:
-(void)applicationWillFinishLaunching:(NSNotification *)notification {
// Become default handler
CFStringRef bundleID = (CFStringRef)CFBridgingRetain([[NSBundle mainBundle] bundleIdentifier]);
OSStatus result = LSSetDefaultHandlerForURLScheme(CFSTR("maxel"), bundleID);
if (result != 0) {
assert(0);
}
}
It will work. 它会工作。 Next turn on sandbox.
接下来打开沙箱。 It will fail with -54 in result.
它将失败,结果为-54。
Built on OSX 10.10 Yosemite. 建立在OSX 10.10 Yosemite上。 Anyone else run into this?
其他人遇到这个?
According to Apple's developer forums, you can't do this anymore in the sandbox--the behavior you are seeing is expected. 根据Apple的开发人员论坛,你不能再在沙盒中这样做 - 你所看到的行为是预期的。 It's really aggravating, because no alternative API exists to implement this functionality, short of stepping outside of the sandbox.
这真的很恶心,因为没有替代API来实现这个功能,而不是走出沙箱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.