问题描述
我希望在自己的应用程序中利用iOS上其他应用程序中的现有功能.据我所知,它应该可以通过URL自定义方案来完成: https://developer. apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
I hope to make use of existing functionalities in other apps on iOS in my own app. To my knowledge it should be able to be done with URL custom schemes:https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
现在在充当监听器的TryingService
gluon应用程序中,我正在使用RuntimeArgsService
监听LAUNCH_URL_KEY
.在此应用程序的Default-Info.plist
文件中,我添加了URL Identifier
:com.tryingservice.TryingService
和URL Scheme
:outputHello
.我应该如何设置我的发送者" Gluon应用程序-用URL Scheme
打开TryingService
应用程序?
Right now in my TryingService
gluon application that are acting as a listener, I am using RuntimeArgsService
to listen for LAUNCH_URL_KEY
. And to my Default-Info.plist
file of this application I have added URL Identifier
: com.tryingservice.TryingService
, and URL Scheme
: outputHello
. How should I set up my "sender" Gluon application - to open the TryingService
application with the URL Scheme
?
现在,我陷入了一个可用的URL:
Right now I am stuck with a functionable URL:
推荐答案
最后,我通过以下示例对ios进行了自定义服务实现: http://docs.gluonhq.com/samples/gonative/
In the end I made a custom service implementation to ios by following this example: http://docs.gluonhq.com/samples/gonative/
这样做时,在学习了一些Objective-C之后,我注意到了JoséPereda在对该问题的评论中已经暗示的BrowserService
,它与我自己的MyService.m
Objective-C文件相似.
When doing this and after learning some Objective-C I noticed the BrowserService
which already had been hinted by José Pereda in the comments to the question - the similarity to my own MyService.m
Objective-C file.
进一步调查之后,请检查"> 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方案.
After investigating this futher the check in 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])
- makes it unavailable to launch my custom URL Scheme.
通过删除BrowserService
中的if
-语句,BrowserService
可以启动另一个已注册URL-Scheme
的应用程序.而且它无需启动safari/默认浏览器就可以做到这一点.
By removing that if
- statement in the BrowserService
the BrowserService
can launch another app that has registered a URL-Scheme
. And it does it without launching safari/default browser can be mentioned.
因此,这是一个Gluon应用程序,它启动了另一个Gluon应用程序(使用RuntimeArgsService
侦听LAUNCH_URL_KEY
)
So here is a Gluon app launching another Gluon app (that listens for LAUNCH_URL_KEY
with RuntimeArgsService
)
何塞(José)也给出了正确的格式:outputHello://<your text here>
.因此,我既可以将其保留为空,也可以在URL-Scheme
部分之后直接添加(例如,向文件的URL).
The correct format also given by José was: outputHello://<your text here>
. So I could both leave it empty or adding (a URL to a file for instance) directly after the URL-Scheme
part.
但是由于iOS应用沙箱,无法从另一个应用读取指向应用本地存储的URL:
However a URL leading to an app's local storage can´t be read from another app due to iOS app Sandbox: 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 .
It should be possible to "open url with options" though as suggested here:https://developer.apple.com/documentation/uikit/uiapplicationopenurloptionskey?language=objc.
这篇关于如何使用Gluon应用程序在iOS上打开/发送URL到另一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!