如何使用Gluon应用程序在iOS上打开/发送URL到另一个应用程序?

时间:2018-01-02 16:29:44

标签: ios communication url-scheme gluon

我希望在我自己的应用程序中使用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 Identifiercom.tryingservice.TryingServiceURL SchemeoutputHello。我应该如何设置我的发送者"胶子应用程序 - 使用TryingService打开URL Scheme应用程序?

现在我遇到了一个功能强大的网址: enter image description here

1 个答案:

答案 0 :(得分:0)

最后,我按照以下示例对ios进行了自定义服务实现:http://docs.gluonhq.com/samples/gonative/

当这样做并且在学习了一些Objective-C之后,我注意到JoséPereda已经在问题的评论中暗示的BrowserService - 与我自己的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])中的检查使其无法启动我的自定义网址方案。

通过删除if中的BrowserService语句,BrowserService URL-Scheme可以启动已注册LAUNCH_URL_KEY的其他应用。它可以在没有启动safari /默认浏览器的情况下进行。

所以这是一个Gluon应用程序启动另一个Gluon应用程序(用RuntimeArgsService收听outputHello://<your text here>enter image description here

José也给出了正确的格式:URL-Scheme。所以我可以将它留空或在/bin/sh部分之后直接添加(例如,文件的URL)。

但是,由于iOS应用沙盒,导致应用本地存储的网址无法从其他应用中读取:What is Sandbox in ios , Can i Trans data between in one App to Another App in iPhone,if possible how

尽管如下所示,应该可以“打开带有选项的网址”: https://developer.apple.com/documentation/uikit/uiapplicationopenurloptionskey?language=objc