Opening your Phonegap Application from email or website using link

Posted By : Deepak Rawat | 31-Mar-2015

Phonegap Application from Email
Hi guys,

Today I will tell you, how you can open your phonegap application using link from email’s or from a website and even from any other phonegap application. You can do this by using a plugin, which helps us to open our phonegap application just by calling your app using a link like myapp://.

First we install this plugin in our phonegap application which we want to open using this cordova CLI command:

 

cordova plugin add https://github.com/EddyVerbruggen/LaunchMyApp-PhoneGap-Plugin.git --variable URL_SCHEME=yourappname

In the above command write a good scheme to replace yourappname, but there are some points which you should remember before writing scheme/app name:

  • Only lowercase characters are allowed.
  • Do not write pre-registered scheme name like twitter,fb,comgooglemaps, etc.
  • Do not use spaces only one word is allowed.
  • Use of Dash(-) is also not allowed, because in Android it became underscore(_).

Now, once you install this plugin in your app you can use it:

  • From email or website to open your app use:

 

<a href=”yourappname://” >Open my app</a>
<a href=”yourappname://somepath” >Open my app</a>
<a href=”yourappname://somepath?abc” >Open my app</a>
  • If calling your app from other phonegap app you have to install InAppBrowser plugin and launch your app like this:

 

<button onclick=”window.open(‘yourappname://’,’_system’)” >Open my app</button>

yourappname is the name which you used to install the plugin in URL_SCHEME.

If you want to do someting after your app will open from URL, then you can implement handleOpenURL(url) method, which is optional and it gives you the URL which is use to open your app.

 

handleOpenURL(url){
console.log(“Your app url ”+url);
};

 

Thanks !!!

 

About Author

Author Image
Deepak Rawat

Deepak is a Web and Mobile application Sr. Lead Frontend developer and good working experience with JQuery , AngularJS , Javascript and PhoneGap. His hobbies are listening to music and photography.

Request for Proposal

Name is required

Comment is required

Sending message..