我正在使用离子框架。我正在尝试设置一种从另一个应用程序接收网址的方法。就像,您在浏览器中,单击共享,然后将链接发送到另一个应用程序(我的应用程序)。我找到了这个cordova https://stackoverflow.com/questions/26008415/receive-url-in-ionic-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 中的相同功能有什么建议吗?
谢谢
所有你需要的是自定义 URL 方案 https://github.com/EddyVerbruggen/Custom-URL-scheme科尔多瓦插件。
您也可以手动完成。
对于 iOS,添加到您的 *.plist。或者你可以看看Step 5 http://code.tutsplus.com/tutorials/ios-sdk-working-with-url-schemes--mobile-6629
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>URL_SCHEME</string>
</array>
</dict>
</array>
在iOS中添加自定义方案后,它会自动调用一个名为的函数handleOpenURL
.
对于android添加AndroidManifest:(在android中你甚至可以监听http方案)
<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)