Deeplinking - Opening an Ionic App through another

2019-08-23 03:33发布

问题:

I'm trying to develope two Ionic applications which are apple to communicate at least in one direction. How do I enable one application to directly open the other one? I have red many things about Deep-Linking but I'm not sure if this is the right way as I only want to open one app (and maybe passing data) through the calling of a function within the other app.

Does anyone have experience with this scenario? I'm happy for every answer!

回答1:

You can use the Custom-URL-scheme plugin

Install it like this:

cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolapp

Then in the other app install cordova-plugin-inappbrowser to open the first app like this:

window.open('mycoolapp://', '_system');

Then install the Custom-URL-scheme plugin in this app with a different variable and use above code with the different variable value to open the other app.

You can get the url (in case you also pass some params) like this:

function handleOpenURL(url) {
  console.log("received url: " + url);
}