在Ionic中接收URL

我正在使用ionic framework。 我试图设置一种方法来接收来自另一个应用程序的url。 就像,你在浏览器中,点击共享,并发送链接到另一个应用程序(我的应用程序)。 我find了这个cordova插件,并将其集成到我的应用程序中。 但是这是Android的 pulgin。 我需要IOS中的相同function。

任何想法哪个插件我需要用于ios

Android为我采取的步骤

1)cordova插件添加git://github.com/Initsogar/cordova-webintent.git 2)检查config.xml文件并findwebintent的代码

<intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> 

和app.js代码

 if (window.plugins && window.plugins.webintent) { window.plugins.webintent.getUri(function(url) { alert("getUri url:"+url); }); } 

任何build议在function上相同的ios?

谢谢

所有你需要的是Custom-URL-scheme的 cordova插件。

你也可以手动执行。 对于iOS添加到您的* .plist。 或者你可以看看第5步

 <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>URL_SCHEME</string> </array> </dict> </array> 

在iOS中添加自定义scheme后,它会自动调用一个名为handleOpenURL的函数。

对于android添加AndroidManifest :(在android中你甚至可以听httpscheme)

 <activity android:label="@string/app_name" android:name="com.yourpackage.name"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="example.com" android:pathPrefix="/" /> <data android:scheme="https" android:host="example.com" android:pathPrefix="/" /> </intent-filter> </activity> 

你问的是你的应用程序的深层链接设施。 虽然我无法为您提供确切的解决scheme,但通过在您的本机ios应用程序的.plist文件中写入几行代码(就像您在manifest.xml中为android所做的那样),它非常简单。 它被称为URL计划 ,你也可以为你的iOS应用程序。

请访问http://docs.urbanairship.com/topic-guides/ios-deep-linking.html 。 我希望它能为你提供如何做到这一点的指导。

打开' 提供了深度链接设施(如YouTube等)的另一个应用程序的angular/离子代码' – https://medium.com/angularjs-articles/deep-linking-in-ionic-mobile-applications-44d8b4685bb3

你正在寻找的是在iOS 8中引入的Action Extension 。你的应用程序将出现在所有系统和第三方应用程序的标准动作/分享表中,并且将能够处理任何types的数据,而不仅仅是URL。

苹果应用程序扩展编程指南

希望这vanger的职位可以帮助你。

在iOS中打开任何应用程序,你需要知道这个应用程序支持哪些urlscheme。

例如,您可以通过URL(如mailto:aaa@bbb.com)打开电子邮件作者。 但是,在应用程序中,您可以声明自己的scheme。 例如在App1中,您可以声明scheme,如“my-app1-scheme”。 而在你的第二个应用程序,你将需要打开URL“my-app1-scheme://”,你的App1将被打开。

我只是发现这个插件,允许你以更简单的方式做到这一点: https : //github.com/EddyVerbruggen/Custom-URL-scheme

在Android上,您可以使用WebIntent插件将您的应用注册为Share意图的接收者。 我不知道是否有类似的扩展程序可用于iOS。

现在似乎有一个插件iOS-Phonegap-app-share-extension 。 我虽然没有尝试。