Install the Calendar plugin: 'ionic plugin add cordova-plugin-calendar' plugin_not_installed

Hi, I have faced a problem with Calendar plugin in Ionic 2 Framework. I am new with it, this is my first project :slight_smile:

Here is my configuration.

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.2
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 3.19
Node Version: v7.4.0
Xcode version: Not installed

“@angular/core”: “2.2.1”,
ionic-native version: ^2.4.1

I am following the instructions: http://ionicframework.com/docs/v2/native/calendar/ to install it, and haven’t any errors during instalation.

But when I tried to use this plugin I had installation error. Looks like Cordova didn’t include it:

Native: tried calling Calendar.hasReadPermission, but the Calendar plugin is not installed.
Install the Calendar plugin: ‘ionic plugin add cordova-plugin-calendar’ plugin_not_installed

Also I have tried to install several plugin from ionic-native list for testing (ĐĄall Number, Geofence) and got the same errors. But Geolocation and Camera are working for me, like described on documentation.

So here is my steps for implementation Calendar plugin:

  1. ionic plugin add cordova-plugin-calendar
  2. import {Calendar} from ‘ionic-native’;
  3. Calendar.createCalendar(‘MyCalendar’).then(
    (msg) => { console.log(msg); },
    (err) => { console.log(err); }
    );
  4. Testing it on phonegap developer app on iOS device.
  5. Builded .apk file, installed it on android, but with different method:
    Calendar.hasReadPermission().then(
    // resolved promise does not return a value
    () => console.log(‘Calendar Plugin Ready’),
    (err) => console.log(err)
    );

Also I was a bit confused with Calendar.js, do I need to include it in index.html file in Ionic 2 (if I am using ionic-native)? As I understand from ionic documentation I do not need to include it?

Anyway I have also tried to include it in index.html, error was disappear, but the code :
Calendar.hasReadPermission().then(
// resolved promise does not return a value
() => console.log(‘Calendar Plugin Ready’),
(err) => console.log(err)
);
didn’t return nothing.

So looks like I am doing something wrong, as a lot of plugins doesn’t work for me, does anyone know what exactly?

Thanks all for any help.

First, check your plugins folder. Is the installed plugin listed there? If not your plugin was not installed when you ran the command and you need to check for errors during the install process. Regardless of this, add the plugin again but pass the --save flag so Ionic saves the plugin to config.xml.

Once you’re sure the folder is there and the line was added to config.xml, check your platforms/android/platform_www/plugins folder and see if your plugin is listed there. If it’s not the plugin wasn’t properly copied over to the Android platform. Try removing the Android platform then adding it back.

Thanks for you answer. Yes it was installed correctly and in platforms/android/platform_www/plugins exists, the problem was in phonegap developer app, it has predefined plugins list which it including during loading. After I have debuged cordova.js and build .apk file, it included correct plugins, so now it works in real device.

So the last question is how to make it work in phonegap developer app, how can I extend platforms/android/platform_www/cordova_plugins.js for phonegap? I tried by adding gap:plugin tag in config.xml but this doesn’t help me :frowning:

The Phonegap Developer App is similar to Ionic View in that it has a defined list of plugins that are part of the native app package that you download from the app store:

http://docs.phonegap.com/references/developer-app/troubleshoot-faq/#which-plugins-are-supported-by-the-phonegap-developer-app-

Only these plugins can be used by your code in this application. If you want to user other plugins, you have to build the native app yourself and debug using this app.