我希望在我自己的应用程序中利用 iOS 上其他应用程序的现有功能。据我所知,它应该能够使用 URL 自定义方案来完成:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
现在在我的TryingService
充当监听器的胶子应用程序,我正在使用 RuntimeArgsService
收听LAUNCH_URL_KEY
.还有我的Default-Info.plist
我已添加此应用程序的文件 URL Identifier
: com.tryingservice.TryingService
, 和 URL Scheme
: outputHello
.我应该如何设置我的“发件人”Gluon 应用程序 - 打开 TryingService
申请 URL Scheme
?
现在我被一个可用的 URL 困住了:
最佳答案
最后,我按照以下示例对 ios 进行了自定义服务实现:http://docs.gluonhq.com/samples/gonative/
这样做时,在学习了一些 Objective-C 之后,我注意到 BrowserService
José Pereda 在对问题的评论中已经暗示了这一点 - 与我自己的相似 MyService.m
objective-C 文件。
在进一步调查后检查 https://bitbucket.org/gluon-oss/charm-down/src/11c36e187921/plugins/plugin-browser/ios/src/main/native/Browser.m?at=default&fileviewer=file-view-default ... if ([[UIApplication sharedApplication] canOpenURL:nsUrl])
- 使其无法启动我的自定义 URL 方案。
通过删除 if
- BrowserService
中的声明BrowserService
可以启动另一个已注册 URL-Scheme
的应用程序.可以提到它在不启动 safari/默认浏览器的情况下完成。
所以这是一个启动另一个 Gluon 应用程序的 Gluon 应用程序(监听 LAUNCH_URL_KEY
和 RuntimeArgsService
)
José 也给出的正确格式是:outputHello://<your text here>
.因此,我既可以将其留空,也可以在 URL-Scheme
之后直接添加(例如文件的 URL)部分。
但是,由于 iOS 应用程序沙盒,无法从另一个应用程序读取指向应用程序本地存储的 URL:What is Sandbox in ios , Can i Trans data between in one App to Another App in iPhone,if possible how
尽管按照此处的建议,应该可以“使用选项打开 url”:
https://developer.apple.com/documentation/uikit/uiapplicationopenurloptionskey?language=objc .
关于ios - 如何使用 Gluon 应用程序打开/发送 URL 到 iOS 上的另一个应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48064507/