微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – Cordova的自定义URL方案

我试图找到一个关于“如何为Cordova应用程序定义自定义URL方案(在iOS和Android平台上)”的好文档.

我在网上花了好几个小时但找不到好的答案.我得到了一些相关但却没有帮助我的链接.

mine是一款在iOS和Android平台上运行的Cordova应用程序.我需要在从电子邮件调用URL时启动我的应用程序(例如:Myapp://).

请告诉我应该使用我的Cordova应用程序进行哪些配置更改以启用此功能.

编辑:
Android清单

<?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.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐