MacOS 给自己的 app 添加 URL Scheme
来源:互联网 发布:nginx访问js报错403 编辑:程序博客网 时间:2024/05/18 20:33
- 一在 Infoplist 中配置CFBundleURLTypesURL Types
- 在 delegate 的 applicationDidFinishLaunching 中添加相应方法
- 验证
一、在 Info.plist 中配置CFBundleURLTypes(URL Types)
source code 模式下的代码
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>com.MelissaShu.MSImagePick</string> <key>CFBundleURLSchemes</key> <array> <string>ms</string> </array> </dict> </array>
配置成功后如下
在 delegate 的 applicationDidFinishLaunching 中添加相应方法
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];}- (void)handleURLEvent:(NSAppleEventDescriptor*)theEvent withReplyEvent:(NSAppleEventDescriptor*)replyEvent { NSString* path = [[theEvent paramDescriptorForKeyword:keyDirectObject] stringValue]; [[NSAlert alertWithMessageText:@"URL Request" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@", path] runModal];}
验证
1、先让程序跑起来;
2、在浏览器中输入 ms://1
(1为随意填写,你也可以改为其他)
会弹出系统窗口,提示你是否打开 app;
3、点击打开后,会出现我们刚写的弹窗,提示刚输入的链接。
这就完成了
参考资料:http://cocoa.venj.me/blog/custom-url-scheme-on-mac-and-ios/
阅读全文
0 0
- MacOS 给自己的 app 添加 URL Scheme
- iphone 给应用添加url URL scheme
- iphone 给应用添加url URL scheme
- iOS 浏览器调用自己的app 自定义URL Scheme
- (其他app跳转自己app)自定义 URL Scheme 完全指南
- 如何找出IOS App的URL Scheme
- 常用第三方APP 的url scheme
- APP url scheme
- 【iOS】通过URL Scheme启动app(收集了常用的app的URL Scheme)
- 在app或者网页打开自己开发的App(Scheme)
- IOS App自定义URL scheme
- 使用URL Scheme启动app
- 通过自定义的URL Scheme启动你的App
- 通过自定义的URL Scheme启动你的App
- 获取一个 app 的 URL Scheme 的方法:
- 通过自定义的URL Scheme启动你的App
- 通过自定义的URL Scheme启动你的App
- 通过自定义的URL Scheme启动你的App
- FPGA双线性插值算法(图像的缩放)
- iOS
- tab切换
- 关于单机oracle数据库的备份教程
- 指针数组与数组指针,指针常量与常量指针
- MacOS 给自己的 app 添加 URL Scheme
- python里把协程变成任务
- 分布式系统时钟同步方案
- 笔记:const与基本数据类型
- JAVA学习---3
- 【demo】Base64加密解密
- Javaweb学习总结(四)
- 双线性插值的图像缩放算法的研究与实现
- 二维码扫描并对扫描结果实现页面传值