I am trying to update the phonegap-1.4.1 project which uses the LocalNotification plugin for Android for cordova-1.6.0
I found this link here: https://github.com/davejohnson/phonegap-plugin-facebook-connect/pull/109 Where it says for Android: use the this.ctx.getContext () method of the CordovaInterface object to get the Conext object .
I edited LocalNotification.java and got my project to compile without errors by changing the following lines:
From:
alarm = new AlarmHelper(this.ctx); ... final SharedPreferences alarmSettings = this.ctx.getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE); ... final Editor alarmSettingsEditor = this.ctx.getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit(); ... final Editor alarmSettingsEditor = this.ctx.getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit(); ... final Editor alarmSettingsEditor = this.ctx.getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();
To:
alarm = new AlarmHelper(this.ctx.getContext()); ... final SharedPreferences alarmSettings = this.ctx.getContext().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE); ... final Editor alarmSettingsEditor = this.ctx.getContext().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit(); ... final Editor alarmSettingsEditor = this.ctx.getContext().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit(); ... final Editor alarmSettingsEditor = this.ctx.getContext().getSharedPreferences(PLUGIN_NAME, Context.MODE_PRIVATE).edit();
However, I have to admit that I really don't know what I'm doing, and the notifications don't work, and I don't get errors in the application log :(
Also noticed that according to the example in my onDeviceReady () function, I have the following:
console.log("Device ready"); if (typeof plugins !== "undefined") { plugins.localNotification.add({ date : new Date(), message : "Phonegap - Local Notification\r\nSubtitle comes after linebreak", ticker : "This is a sample ticker text", repeatDaily : false, id : 4 }); }
If I remove a condition like typeof plugins! == "undefined", then I get an error in my application log, which is: Uncaught ReferenceError: plugins not defined
I guess something else has changed in Cordoba. If there is somewhere a guide on updating plugins for Android to Cordova, if it would be useful.