Home » Android » Open Cordova Android App from Calendar

Open Cordova Android App from Calendar

Posted by: admin June 15, 2020 Leave a comment

Questions:

Hi I am using EddyVerbruggen/Calendar-PhoneGap-Plugin in my ionic app to save calendar events.

What I want to achieve is when I go my calendar and click on that event I want to open my app.
How to do that?

How to&Answers:

You won’t be able to override calendar functionality to direct to your
ionic application.You can only open your ionic app via custom links.

How to open ionic application using custom url?

Mobile applications made with Ionic Framework can leverage custom URL schemes by using a plugin LaunchMyApp

Add the plugin into our project.

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

Where the command --variable URL_SCHEME=ionicapp is essential otherwise the plugin will fail to add. Then you will be able to launch your application from any URL that starts like this:

ionicapp://

You could listen in your application for various URL paths and parameters and have your application do various things depending. Add the following code globally:

var handleOpenURL = function(url) {
    alert("RECEIVED URL: " + url);
};

Tutorial