我正在尝试找到一份关于“如何为 Cordova 应用程序(在 iOS 和 Android 平台上)定义自定义 URL 方案”的好文档。
我在互联网上花了几个小时,但找不到好的答案。我得到了一些相关但对我帮助不大的链接。
Mine 是一个在 iOS 和 Android 平台上运行的 Cordova 应用程序。我需要启用我的应用程序,以便在从电子邮件中调用 URL(例如:Myapp://)时启动。
请告诉我应该对我的 Cordova 应用程序进行哪些配置更改以启用此功能。
编辑: 安卓 list
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.simple.app" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="com.test.simple" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
网址
<a href="com.test.simple://">Launch The App</a>
最佳答案
我知道您特别要求提供有关如何自己手动编码的文档,但仅供引用,有一个不错的插件可以为您完成所有(相当多的!)工作:
https://github.com/EddyVerbruggen/Custom-URL-scheme
安装时,您只需提供要用于启动应用程序的 URL 架构:
$ cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=myCustomUrlScheme
这就是它的全部内容。适用于 Android 和 iOS。
关于android - Cordova 的自定义 URL 方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30998648/