我正在使用 ionic 框架。我正在尝试设置一种方法来从另一个应用程序接收 url。比如,您在浏览器中,单击共享,然后将链接发送到另一个应用程序(我的应用程序)。我找到了这个 cordova插件,并将其集成到我的应用程序中。但这是 Android 的插件。我在 IOS 中需要相同的功能。
知道我需要为 ios 使用哪个插件吗
我为 Android 采取的步骤
1) cordova插件添加git://github.com/Initsogar/cordova-webintent.git 2) 查看config.xml文件,找到webintent的代码
<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);
});
}
对于 ios 中相同功能的任何建议?
谢谢
最佳答案
您只需要 Custom-URL-scheme Cordova 插件。
您也可以手动完成。 对于 iOS,添加到您的 *.plist。或者你可以看看Step 5
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>URL_SCHEME</string>
</array>
</dict>
</array>
在 iOS 中添加自定义方案后,它会自动调用名为 handleOpenURL
的函数。
对于android添加AndroidManifest:(在android中你甚至可以监听http scheme)
<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>
关于ios - 在 Ionic for ios 中接收 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30432410/