EddyVerbruggen / Custom-URL-scheme

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

This plugin overrides intent-filter provided by cordova-universal-links-plugin #244

Open slorber opened 7 years ago

slorber commented 7 years ago

Hi,

I need in my app both deep linking (with cordova-universal-links-plugin, not hacky redirect) and custom url scheme.

The "universal link" plugin needs to setup manifest:

      <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:host="stample.co" android:scheme="https" android:pathPattern="/link/.*"/>
      </intent-filter>

But just afterward, the "custom url scheme" plugin overrides that declaration with:

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

I'm not an Android developer at all but this seems wrong to be. The documentation of Android mention that a data tag without at least a scheme does not make sense. Not sure what this plugin tries to achieve here: any idea?

Here's the commit from @EddyVerbruggen

It could be nice to make sure that both plugins work fine together. Thanks

slorber commented 7 years ago

Not sure it's related to the above PR/commits finally because I can reproduce the override by using v2.1.5.

Any idea on how we could avoid this override?

slorber commented 7 years ago

There's hopefully a workaround by configuring both plugin to support deep linking (note one use pathPrefix while the other use pathPattern params)

    <universal-links>
        <ios-team-id value="xxx" />
        <host name="stample.co" scheme="https">
            `<path url="/link/*" />
        </host>
    </universal-links>
    <plugin name="cordova-plugin-customurlscheme" spec="4.2.0">
        <variable name="URL_SCHEME" value="stample" />
        <variable name="ANDROID_SCHEME" value="https" />
        <variable name="ANDROID_HOST" value="stample.co" />
        <variable name="ANDROID_PATHPREFIX" value="/link" />
    </plugin>
slorber commented 7 years ago

I've found a better workaround for this issue.

It looks like config.xml declaration order matters. If I put <universal-links> after the <plugin name="cordova-plugin-customurlscheme" spec="4.2.0">, I am able to get the expected android manifest