Hari Muniswaran
Posts: 0
Joined: Sun Jul 27, 2014 6:29 am

Unable to add third party phonegap calendar plugin to appery.io

Hi I am trying to add the phonegap calendar plugin to appery.io and I need help

I have followed the tutorial as mentioned in http://devcenter.appery.io/documentat...

and it does not work

I keep getting an error stating that the calendar and cordova are undefined

all I am trying to to is to click a button ad create a calendar event

Any help regarding this is extremely appreciated

Hari Muniswaran
Posts: 0
Joined: Sun Jul 27, 2014 6:29 am

Unable to add third party phonegap calendar plugin to appery.io

The js file is as follows

function CalendarPlugin() {}

CalendarPlugin.prototype.createEvent = function(title, location, notes, startDate, endDate, successCallback, errorCallback) {
if (typeof errorCallback != "function") {
console.log("CalendarPlugin.createEvent failure: errorCallback parameter must be a function");
return;
}

Code: Select all

 if (typeof successCallback != "function") { 
     console.log("CalendarPlugin.createEvent failure: successCallback parameter must be a function"); 
     return; 
 } 
 cordova.exec(successCallback, errorCallback, "CalendarPlugin", "createEvent", [title, location, notes, startDate, endDate, { 
     "title": title, 
     "description": notes, 
     "eventLocation": location, 
     "startTimeMillis": startDate.getTime(), 
     "endTimeMillis": endDate.getTime() 
 }]); 

};

CalendarPlugin.install = function() {
if (!window.plugins) {
window.plugins = {};
}

Code: Select all

 window.plugins.CalendarPlugin = new CalendarPlugin(); 
 return window.plugins.CalendarPlugin; 

};

cordova.addConstructor(CalendarPlugin.install);

The Java file is as follows

package de.drid.calendarPlugin;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;
import android.content.Intent;

public class CalendarPlugin extends CordovaPlugin {
public static final String ACTION_ADD_CALENDAR_ENTRY = "createEvent";

Code: Select all

 @Override 
 public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { 
     try { 
         if (ACTION_ADD_CALENDAR_ENTRY.equals(action)) {  
             JSONObject arg_object = args.getJSONObject(5); 
             Intent calIntent = new Intent(Intent.ACTION_EDIT) 
                 .setType("vnd.android.cursor.item/event") 
                 .putExtra("beginTime", arg_object.getLong("startTimeMillis")) 
                 .putExtra("endTime", arg_object.getLong("endTimeMillis")) 
                 .putExtra("title", arg_object.getString("title")) 
                 .putExtra("description", arg_object.getString("description")) 
                 .putExtra("eventLocation", arg_object.getString("eventLocation")); 

                this.cordova.getActivity().startActivity(calIntent); 
                callbackContext.success(); 
                return true; 
         } 
         callbackContext.error("Invalid action"); 
         return false; 
     } catch(Exception e) { 
         System.err.println("Exception: " + e.getMessage()); 
         callbackContext.error(e.getMessage()); 
         return false; 
     }
Hari Muniswaran
Posts: 0
Joined: Sun Jul 27, 2014 6:29 am

Unable to add third party phonegap calendar plugin to appery.io

I have a button name= Alert

I have created an click event and I am running a javascript

var title = "New Years party";
var location = "The Club";
var notes = "Bring pizza.";
var start = new Date(2015,0,1,20,0,0,0,0); // Jan 1st, 2015 20:00
var end = new Date(2015,0,1,22,0,0,0,0); // Jan 1st, 2015 22:00
var calendarName = "MyCal";

var success = function(message) {alert("Success: " + JSON.stringify(message))};
var error = function(message) {alert("Error: " + message)};
CalendarPlugin.createEvent(title, location, notes, start, end, success, error);

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Unable to add third party phonegap calendar plugin to appery.io

Hi Hari,

Could you please clarify are you testing this on a device?
And can you show what plugin exactly you're adding.

Hari Muniswaran
Posts: 0
Joined: Sun Jul 27, 2014 6:29 am

Unable to add third party phonegap calendar plugin to appery.io

Hi Illya,
when I test it on a device clicking the button Alert button displays error Error:Class not found

When I test it on a browser I get an error stating that the calendarPlugin and cordova are undefined

The plugin that I am trying to add is to create a calendar event when user taps on a button

I have pasted the javascript and the Java class along with the javascript that I call onclick

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Unable to add third party phonegap calendar plugin to appery.io

How you adding this plugin? Can you show the link to source?

Return to “Issues”