0

I built an app using Cordova 11, which I'm now trying to launch from a web link and potentially go to a specific screen in the app.

So far, with the aid of necessary config (config.xml, assetlinks.json in the correct directory on the web server), I've been able to have the app launch on a Samsung Galaxy Tab A when a link is clicked.

However, I still need some way to tell it to do something in the app (navigate somewhere else, display a message, etc).

In the Cordova world, I assume I need a plugin for this. There doesn't seem to be much out there, but I've found Darryn Campbell's fork(?) of the Intent plugin at https://www.npmjs.com/package/com-darryncampbell-cordova-plugin-intent

With the following code in mounted() in a Vue.js page,

  if (typeof window.plugins.intentShim !== 'undefined') {
    console.log('*intentShim defined*')
    this.hasIntentShim = true

    console.log('getIntent call starting') //  *A*
    window.plugins.intentShim.getIntent(function (intent) {
      _this.intentShimDetails = JSON.stringify(intent)
      console.log('* intent details = ' + JSON.stringify(intent)) // *B*
    },
    function () {
      console.log('error getting intent')
    })
    console.log('getIntent call completed') // *C*
  }

And using USB debugging with Android Studio I can see output from lines A and C but not B.

Am I doing it right? When does getIntent get called?

Is there a better Cordova plugin out there for working with Intents?

1 Answer 1

0

There is a better plugin for that I believe. Check out cordova-plugin-customurlscheme

Usage
1a. Your app can be launched by linking to it like this from a website or an email for example (all of these will work):

<a href="mycoolapp://">Open my app</a>
<a href="mycoolapp://somepath">Open my app</a>
<a href="mycoolapp://somepath?foo=bar">Open my app</a>
<a href="mycoolapp://?foo=bar">Open my app</a>
1
  • Thanks for this! Do you have any sample code or idea where the intent would be handled in Vue? e.g. for somepath?foo=bar, where would you get ahold of somepath and the value of foo?
    – Colin M
    Commented Mar 14, 2023 at 14:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.