Opening your Phonegap Application from email or website using link
Posted By : Deepak Rawat | 31-Mar-2015
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 !!!
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
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.