对于科尔多瓦自定义URL方案 [英] Custom URL scheme for Cordova

查看:186
本文介绍了对于科尔多瓦自定义URL方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出的如何定义一个应用科尔多瓦定制URL方案(两个iOS和Android平台)的好文件。

我花了互联网上的时间也没有找到一个很好的答案。我得到了一些这是相关但不链接帮助我很多。

我的是它运行在iOS和Android平台的应用程序科尔多瓦。我需要让我的应用程序在从邮件调用URL(例如:MYAPP://)启动。

请告诉我哪些配置更改我应该maketo我科尔多瓦应用程序来启用此功能。

编辑:
Android清单

 < XML版本='1.0'编码='UTF-8'&GT?;
<表明机器人:hardwareAccelerated =真正的安卓版code =1机器人:=的versionName0.0.1包=com.simple.app的xmlns:机器人=HTTP://模式。 android.com/apk/res/android\">
    <支持屏安卓anyDensity =真正的机器人:largeScreens =真正的机器人:normalScreens =真正的机器人:调整大小=真正的机器人:smallScreens =真正的机器人:xlargeScreens =真/>
    <使用许可权的android:NAME =android.permission.INTERNET对/>
    <应用机器人:hardwareAccelerated =真正的机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME机器人:supportsRtl =真正的>
        <活动机器人:configChanges =方向| keyboardHidden |键盘|屏幕尺寸|区域机器人:标签=@字符串/ ACTIVITY_NAME机器人:launchMode =singleTop机器人:名字=MainActivity安卓主题=@机器人:风格/ Theme.Black.NoTitleBar机器人:windowSoftInputMode =adjustResize>
            <意向过滤器的android:标签=@字符串/ LAUNCHER_NAME>
                <作用机器人:名字=android.intent.action.MAIN/>
                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
            &所述;意图滤光器>
                <数据机器人:计划=com.test.simple/>
                <作用机器人:名字=android.intent.action.VIEW/>
                <类机器人:名字=android.intent.category.DEFAULT/>
                <类机器人:名字=android.intent.category.BROWSABLE/>
            &所述; /意图滤光器>
        < /活性GT;
    < /用途>
    <采用-SDK安卓的minSdkVersion =10机器人:targetSdkVersion =21/>
    <使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
< /清单>

网址

 < A HREF =com.test.simple://>启动应用程序< / A>


解决方案

我知道,你是专为文档询问如何给自己手工code这一点,但只是FYI有一个很好的插件,将尽一切在(!相当数量的)的为你工作:

  https://github.com/EddyVerbruggen/Custom-URL-scheme

当你安装它,你只需要提供你想要用来启动应用程序的URL方案:

  $科尔多瓦插件添加https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME = myCustomUrlScheme

这就是pretty很多都在那里给它。适用于Android和iOS。

I am trying to find out a good document on "How to define custom URL scheme for a Cordova app(on both iOS and Android platforms)".

I have spent hours on internet but couldn't find a good answer. I got some links which are related but not helping me much.

Mine is a Cordova app which runs on iOS and Android platforms. I need to enable my app to be started upon invoking a URL from email(ex: Myapp://).

Please advise me what configuration changes should I maketo my Cordova app to enable this feature.

EDIT: Android manifest

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

Url

<a href="com.test.simple://">Launch The App</a>

解决方案

I know that you are specifically asking for documentation about how to hand-code this yourself, but just FYI there is a nice plugin that will do all of the (considerable amount of!) work for you:

https://github.com/EddyVerbruggen/Custom-URL-scheme

When you install it, you just provide the URL scheme that you want to use to launch your app:

$ cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=myCustomUrlScheme

And that's pretty much all there is to it. Works on Android and iOS.

这篇关于对于科尔多瓦自定义URL方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆