Eddy Verbruggen's Calendar plugin with ionic

I’m trying to use Eddy Verbruggen’s Calendar Plugin. But since Ionic has no real plugin support can’t seem to get it working.

The default window.plugins.calendar functions from the Readme don’t work since window.plugins results in an undefined.

Could anybody here put me in the right direction?

1 Like

The Calendar plugin you speak of is a Cordova plugin. Ionic does indeed support plugins (more like directives, factories and services) but they exist as Angular extensions, not plugins that enable device functionality like Cordova plugins. So Cordova plugins won’t work when you run your Ionic project in your browser, they will only work when you run your project from either a simulator or a device.

  1. So have you added the plugin with cordova plugin add https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin.git from the terminal in your project directory?
  2. Are you running the project from a simulator or device?

When you’re running the project from a simulator or device and you open Safari / Chrome with the dev tools and inspect your project and you type in window.plugins from the terminal and undefined is returned, the plugin hasn’t been correctly installed within your project.

I have added the plugin with cordova plugin add etc.
I run it in an ios emulator, when I run it with the debug flag I see that it adds the plugin to cordovaplugin.js as it should

Here is the code I’m trying to get to work, I wired an alert message to either a failure or a success response from the calendar function, but I don’t get anyting.

 $scope.newEvent = function() {
   // prep some variables
   var calendarName = "new Calendar";
   var startDate = new Date("September 24, 2013 13:00:00");
   var endDate = new Date("September 24, 2013 14:30:00");
   var title = "My nice event";
   var location = "Home";
   var notes = "Some notes about this event.";
   var success = function(message) { alert("Success: " + JSON.stringify(message)); };
   var error = function(message) { alert("Error: " + message); };

  // create a calendar (iOS only for now)
  window.plugins.calendar.createCalendar(calendarName,success,error);
}

I call this code from a button click in my controller.

Can you verify that the plugin has in fact loaded by opening up Safari / Chrome and inspecting your app with the dev tools? Just open up the js console and type in window.plugins.calendar and press enter. What is the response?

jup, running the dev tools and entering window.plugins.calendar gives back the calendar object.

So it works, no ? window.plugins isn’t undefined in your screenshot.

Oh wow, cleaning and rebuilding my project worked in the end, probably borked something up along the way. Thanks anyways!

Always cordova build ios after every change to your www folder… learned that one the hard way :wink: Good luck!

1 Like

I run the command

cordova plugin add https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin.git

and now when i do ionic build ios, I got

clang: error: no such file or directory: '/Users/username/src/myApp/platforms/ios/myApp/Plugins/nl.x-services.plugins.calendar/Calendar.m'

It seems that file is missing. Should I just manually copy it there?

I’m facing the same problm, di dyou solve it? I also tried adding manually the plugin, but I see the error: Reference Error: can’t find variable cordova (Calendar.js:218)

am new to mobile dev

does it work on android
i was following this tutorial and am having hardluck

this is my log when i click on create event on my emulator

any suggestions

ystem.err( 3046): Exception: null
W/PluginManager( 3046): THREAD WARNING: exec() call to Calendar.createEventWithOptions blocked the main thread for 172ms. Plugin should use CordovaInt
erface.getThreadPool().
W/CordovaPlugin( 3046): Attempted to send a second callback for ID: Calendar1729418646
W/CordovaPlugin( 3046): Result was: "Invalid action"
D/CordovaLog( 3046): file:///android_asset/www/js/app.js: Line 26 : There was an error: null
E/Web Console( 3046): There was an error: null at file:///android_asset/www/js/app.js:26
I/CalendarProvider2( 933): Sending notification intent: Intent { act=android.intent.action.PROVIDER_CHANGED dat=content://com.android.calendar }
W/ContentResolver( 933): Failed to get type for: content://com.android.calendar (Unknown URL content://com.android.calendar)
D/AlertReceiver( 828): onReceive: a=android.intent.action.PROVIDER_CHANGED Intent { act=android.intent.action.PROVIDER_CHANGED dat=content://com.andr
oid.calendar flg=0x10 cmp=com.android.calendar/.alerts.AlertReceiver }
D/AlertService( 828): 0 Action = android.intent.action.PROVIDER_CHANGED
D/AlertService( 828): Beginning updateAlertNotification
D/AlertService( 828): No fired or scheduled alerts

I have add plugin with cordova plugin I want to open calendar with event.
I have Event Id and name of Calendar but I am not able to open event directly. now in this plugin I can only open calendar with the specific date but I want to open calendar with event opened in it.

can anyone help me out with this problem

I am trying to create two days daily recuring event but event is displaying for only one day,

its not taking end date