I added the plugin https://github.com/EddyVerbruggen/Custom-URL-scheme to my cordova project.
The plugin has this in the plugin.xml file for Android:
<config-file target="AndroidManifest.xml" parent="/manifest/application/activity">
<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="$URL_SCHEME"/>
</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="$ANDROID_SCHEME"
android:host="$ANDROID_HOST"
android:pathPrefix="$ANDROID_PATHPREFIX" />
</intent-filter>
</config-file>
When installing the plugin I provide the value for the CUSTOM_URL variable:
cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=appscheme
Then I run the app in emulator with cordova run android --emulator. The Android Manifest is generated correctly including both intent filter blocks:
<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="appscheme"/>
</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=" " android:host=" " android:pathPrefix="/" />
</intent-filter>
And things work as expected.
But if I then make any change to my project, and rebuild the app by running cordova run android again, then one of the intent filter blocks is missing from the Android Manifest file, and the plugin functionality doesn't work.
<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=" " android:host=" " android:pathPrefix="/" />
</intent-filter>
I need to remove the plugin, and then add it back, for the AndroidManifest.xml to be generated correctly.
Any idea why it would remove one of the intent-filter blocks when rebuilding?
Thanks for any help!