ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android – Cordova的自定义URL方案

2019-05-19 20:12:46  阅读:263  来源: 互联网

标签:android ios cordova phonegap-build


我试图找到一个关于“如何为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.

标签:android,ios,cordova,phonegap-build
来源: https://codeday.me/bug/20190519/1137277.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有