简体   繁体   English

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

[英]How can I open/send a URL to another app on iOS with a Gluon application?

I hope to make use of existing functionalities in other apps on iOS in my own app. 我希望在自己的应用程序中利用iOS上其他应用程序中的现有功能。 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 据我所知,应该可以使用URL自定义方案完成: https : //developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html

Right now in my TryingService gluon application that are acting as a listener, I am using RuntimeArgsService to listen for LAUNCH_URL_KEY . 现在,在充当侦听器的TryingService应用程序中,我正在使用RuntimeArgsService侦听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 . 在此应用程序的Default-Info.plist文件中,我添加了URL Identifiercom.tryingservice.TryingServiceURL SchemeoutputHello How should I set up my "sender" Gluon application - to open the TryingService application with the URL Scheme ? 我应该如何设置我的“发送者” TryingService应用程序-使用URL Scheme打开TryingService应用程序?

Right now I am stuck with a functionable URL: 现在,我陷入了一个可用的URL: 在此处输入图片说明

In the end I made a custom service implementation to ios by following this example: http://docs.gluonhq.com/samples/gonative/ 最后,我通过遵循以下示例对ios进行了自定义服务实现: http : //docs.gluonhq.com/samples/gonative/

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. 这样做时,在学习了一些Objective-C之后,我注意到JoséPereda在对该问题的评论中已经暗示了BrowserService -与我自己的MyService.m Objective-C文件相似。

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. 在进一步调查之后,请检查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方案。

By removing that if - statement in the BrowserService the BrowserService can launch another app that has registered a URL-Scheme . 通过移除if -语句在BrowserServiceBrowserService可以启动已注册的其他应用程序URL-Scheme And it does it without launching safari/default browser can be mentioned. 而且它无需启动野生动物园/默认浏览器就可以做到。

So here is a Gluon app launching another Gluon app (that listens for LAUNCH_URL_KEY with RuntimeArgsService ) 因此,这是一个Gluon应用程序,它启动了另一个LAUNCH_URL_KEY应用程序(使用RuntimeArgsService监听LAUNCH_URL_KEY 在此处输入图片说明

The correct format also given by José was: outputHello://<your text here> . José还给出了正确的格式是: 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. 因此,我既可以将其保留为空,也可以在URL-Scheme部分之后直接添加(例如,向文件添加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 但是,由于iOS应用程序沙箱,导致无法从另一个应用程序读取导致应用程序本地存储的URL: ios中的沙盒是什么,如果可以的话,我可以在一个应用程序与另一个应用程序之间传输数据吗?

It should be possible to "open url with options" though as suggested here: https://developer.apple.com/documentation/uikit/uiapplicationopenurloptionskey?language=objc . 尽管可以按照此处的建议进行操作,但应该可以“使用选项打开URL”: https : //developer.apple.com/documentation/uikit/uiapplicationopenurloptionskey?language=objc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM