Skip to content

Instantly share code, notes, and snippets.

@webberig
Last active January 14, 2021 12:31
Show Gist options
  • Save webberig/5778cce436c547d98cc4904e7d78d743 to your computer and use it in GitHub Desktop.
Save webberig/5778cce436c547d98cc4904e7d78d743 to your computer and use it in GitHub Desktop.
ionic-plugin-deeplinks Android pathPattern support

This Gist relates to the following Cordova plugin: https://github.com/ionic-team/ionic-plugin-deeplinks

It contains a workaround for the following issue: ionic-team/ionic-plugin-deeplinks#130

The plugin only supports configuration that adds "pathPrefix" url configuration. Android also supports wildcards by using "pathPattern" parameters, but the plugin does not allow to configure this.

The gist adds a Cordova hook that manipulates the AndroidManifest.xml file before performing a build. It cleans up any wrongful configuration and addds pathPattern configuration.

Installation

  • Create a file scripts/fixAndroidDeepLinks.js in your project and copy the contents of this gist file
  • Configure the deeplinkPatterns (tip: you can add any number of patterns you need)
  • Configure a proper hostname and scheme (should be https)
  • Addd the hook command in your config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="..." version="1.4.3" xmlns="http://www.w3.org/ns/widgets">
<platform name="android">
<hook src="scripts/fixAndroidDeepLinks.js" type="after_prepare" />
</platform>
</widget>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment