我使用以下代码为我的 Cocoa 应用程序注册了一个自定义 URL 方案 (myscheme://):
-(void)applicationWillFinishLaunching:(NSNotification *)notification {
CFStringRef bundleId = (__bridge CFStringRef)[[NSBundle mainBundle] bundleIdentifier];
LSSetDefaultHandlerForURLScheme(CFSTR("myscheme"), bundleId);
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
}
当我安装应用程序时,它会为该用户注册 URL 方案,并能够通过 Safari 浏览器(如 myscheme://abcd)打开。
当我切换到不同的用户并尝试相同的场景时,我无法打开 URL 方案并且它无法显示以下消息:
找不到 URI myscheme://abcd 的应用程序
为所有用户注册 URL 方案是否需要额外注册?
谢谢