Issue
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?
Solution
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>
Answered By - Eric
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.