EddyVerbruggen / Custom-URL-scheme

:link: Launch your Cordova/PhoneGap app by a Custom URL scheme like mycoolapp://
1.03k stars 365 forks source link

Custom URL scheme not being called on Android #255

Closed daveywc closed 6 years ago

daveywc commented 6 years ago

My custom URL scheme in an Ionic app is working fine on iOS. But on Android the scheme does not appear to be recognised. All that I've done to test is just to type in my scheme name into a browser: "docsontapv2://".

I installed using the CLI and have the following values in my config.xml file:

 <plugin name="cordova-plugin-customurlscheme" spec="^4.3.0">
        <variable name="URL_SCHEME" value="docsontapv2" />
        <variable name="ANDROID_SCHEME" value=" " />
        <variable name="ANDROID_HOST" value=" " />
        <variable name="ANDROID_PATHPREFIX" value="/" />
    </plugin>

I checked the built AndroidManifest.xml and it has the following added:

<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" 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>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="docsontapv2" />
            </intent-filter>
            <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:host=" " android:pathPrefix="/" android:scheme=" " />
            </intent-filter>
        </activity>

Is there something else that I need to do to get things working in Android?

Thanks,

David

akadebnath commented 6 years ago

In your Android manifest file, you need this:

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>
daveywc commented 6 years ago

I did add that to my manifest file and it did not help.

vyarmolik commented 6 years ago

Launching an app by typing an app-specific URL in a browser address bar will work on iOS only. It will not work on Android: https://developer.chrome.com/multidevice/android/intents

daveywc commented 6 years ago

@vyarmolik Thanks for your response. Your advise was the key. I ended up changing to use the Ionic Deep Linking plugin and using a standard URL for my link (which was embedded in a calendar entry).