Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to get the Android LocalNotification plugins for phonegap to work in cordova-1.6.0
    text
    copied!<p>I'm trying to upgrade a phonegap-1.4.1 project that uses the LocalNotification plugin for Android to cordova-1.6.0 </p> <p>I found this link here: <a href="https://github.com/davejohnson/phonegap-plugin-facebook-connect/pull/109" rel="nofollow">https://github.com/davejohnson/phonegap-plugin-facebook-connect/pull/109</a> Where it says, For Android: use this.ctx.getContext() method of CordovaInterface object to get Conext object.</p> <p>I edited LocalNotification.java and got my project to compile without errors by changing the following lines:</p> <h1>From:</h1> <pre><code>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(); </code></pre> <h1>To:</h1> <pre><code>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(); </code></pre> <p>However I must admit that I don't really know what I'm doing and the notifications don't work and I don't get any errors in the applications log :( </p> <p>Also just noticed that as per the example in my onDeviceReady() function I have the following:</p> <pre><code>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 }); } </code></pre> <p>If I remove the the if condition typeof plugins !== "undefined" then I get an error in my app log which is: Uncaught ReferenceError: plugins is not defined</p> <p>I guess something else as changed in cordova. If there is a guide somewhere for upgrading android plugins to cordova if would be useful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload