Wizcorp / phonegap-plugin-localNotifications

PhoneGap plugin for providing native local notification system to JavaScript.
MIT License
38 stars 29 forks source link

Problems with AlarmRestoreOnBoot #30

Open simongcx opened 9 years ago

simongcx commented 9 years ago

I am encountering problems with the AlarmRestoreOnBoot functionality on Android 4.4.4 with a Cordova 3.5.1 app built in Intel XDK using release 2.1.0 of this plugin.

To test, I am creating 100 notifications 1 minute apart, then restarting the phone. I get not subsequent notifications, but the phone does a lot of vibrating just after boot, which I think is due to processing the notifications that don't have a time set.

In adb I have simulated a reboot with:

adb shell am broadcast -a android.intent.action.BOOT_COMPLETED

With adb logcat -s LocalNotification I get approximately 100 of the following message:

D/LocalNotification(31810): AlarmRestoreOnBoot: Successfully restored alarms upon reboot

Followed by approximately 100 of the following series of three messages:

E/LocalNotification(  470): Unable to process alarm with id: 
D/LocalNotification(  470): Notification Instantiated: Title: , Sub Title: , Ticker Text: 
D/LocalNotification(  470): Notification created!

As there is no ID, title, ticker, etc, I hypothesise that the addAlarm called from AlarmRestoreOnBoot is where the problem is occuring (not in the AlarmReceiver class).

However, a commonality between this issue and the one I have encountered with cancelAll() #29 , may suggest an issue with the getSharedPreferences code.

simongcx commented 9 years ago

AlarmOptions.parseOptions expects the JSONObject to have a "date" field, at string in the format month/day/year/hour/min. As far as I can see, the data that is put into the SharedPreferences is exactly the JSON object passed from the javascript interface file, and the documentation does not suggest a "date" field is required (the time of the notification is communicated in the "seconds" property").

Where is the "date" property set?

Has the AlarmRestoreOnBoot actually been sucessfully tested?