Commit 235c49ee by Sebastián Katzer

Repeat with shorter/curstom intervals (#27)

parent 10c6988c
...@@ -50,8 +50,10 @@ More informations can be found [here](https://build.phonegap.com/plugins/331). ...@@ -50,8 +50,10 @@ More informations can be found [here](https://build.phonegap.com/plugins/331).
- [bugfix:] App throws an error on iOS if `message` is null. - [bugfix:] App throws an error on iOS if `message` is null.
- [bugfix:] Removed extra line break on iOS if `title` is null or empty. - [bugfix:] Removed extra line break on iOS if `title` is null or empty.
- [bugfix:] Notification on iOS will be canceled if a new one with the same ID was added. - [bugfix:] Notification on iOS will be canceled if a new one with the same ID was added.
- [enhancement:] Added `autoCancel` flag. - [feature:] Added `autoCancel` flag.
- [bugfix:] `cancel` on iOS did not work. - [bugfix:] `cancel` on iOS did not work.
- [enhancement:] Added 'hourly' as a new repeat time aliase.
- [feature:] Repeat with custom intervals on Android.
#### Version 0.6.3 (12.12.2013) #### Version 0.6.3 (12.12.2013)
- [bugfix:] Black screen on Android. - [bugfix:] Black screen on Android.
...@@ -105,7 +107,7 @@ window.plugin.notification.local.add({ ...@@ -105,7 +107,7 @@ window.plugin.notification.local.add({
date: Date, // This expects a date object date: Date, // This expects a date object
message: String, // The message that is displayed message: String, // The message that is displayed
title: String, // The title of the message title: String, // The title of the message
repeat: String, // Has the options of daily', 'weekly',''monthly','yearly') repeat: String, // Has the options of 'hourly', 'daily', 'weekly', 'monthly', 'yearly'
badge: Number, // Displays number badge to notification badge: Number, // Displays number badge to notification
sound: String, // A sound to be played (iOS & Android) sound: String, // A sound to be played (iOS & Android)
autoCancel: Boolean, // Setting this flag and the notification is automatically canceled when the user clicks it autoCancel: Boolean, // Setting this flag and the notification is automatically canceled when the user clicks it
...@@ -160,12 +162,6 @@ window.plugin.notification.local.add({ message: 'Great app!' }); ...@@ -160,12 +162,6 @@ window.plugin.notification.local.add({ message: 'Great app!' });
```javascript ```javascript
window.plugin.notification.local.add({ sound: null }); window.plugin.notification.local.add({ sound: null });
``` ```
#### Cancel notification immediatly after creation
```javascript
window.plugin.notification.local.add({ id: 1, message: 'Reminder' });
// `add` is executed asynchron!
setTimeout('plugin.notification.local.cancel(1)', 200);
```
## Platform specifics ## Platform specifics
...@@ -218,6 +214,13 @@ An image must be defined as a relative or absolute URI. ...@@ -218,6 +214,13 @@ An image must be defined as a relative or absolute URI.
window.plugin.notification.local.add({ image: 'appdata:ApplicationIcon.png' }) window.plugin.notification.local.add({ image: 'appdata:ApplicationIcon.png' })
``` ```
All images can be restored to the default ones by canceling the notification. All images can be restored to the default ones by canceling the notification.
### Custom repeating interval on Android
To specify a custom interval, the `repeat` property can be assigned with an number in minutes.
```
/**
* Schedules the notification quarterly every 15 mins
*/
window.plugin.notification.local.add({ repeat: 15 });
## Quirks ## Quirks
......
...@@ -57,7 +57,9 @@ public class Options { ...@@ -57,7 +57,9 @@ public class Options {
this.options = options; this.options = options;
if (repeat.equalsIgnoreCase("daily")) { if (repeat.equalsIgnoreCase("hourly")) {
interval = AlarmManager.INTERVAL_HOUR;
} if (repeat.equalsIgnoreCase("daily")) {
interval = AlarmManager.INTERVAL_DAY; interval = AlarmManager.INTERVAL_DAY;
} else if (repeat.equalsIgnoreCase("weekly")) { } else if (repeat.equalsIgnoreCase("weekly")) {
interval = AlarmManager.INTERVAL_DAY*7; interval = AlarmManager.INTERVAL_DAY*7;
...@@ -65,6 +67,8 @@ public class Options { ...@@ -65,6 +67,8 @@ public class Options {
interval = AlarmManager.INTERVAL_DAY*31; // 31 days interval = AlarmManager.INTERVAL_DAY*31; // 31 days
} else if (repeat.equalsIgnoreCase("yearly")) { } else if (repeat.equalsIgnoreCase("yearly")) {
interval = AlarmManager.INTERVAL_DAY*365; interval = AlarmManager.INTERVAL_DAY*365;
} else {
interval = Integer.getInteger(repeat, 0) * 60000;
} }
return this; return this;
......
...@@ -148,10 +148,11 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION"; ...@@ -148,10 +148,11 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
{ {
NSMutableDictionary* repeatDict = [[NSMutableDictionary alloc] init]; NSMutableDictionary* repeatDict = [[NSMutableDictionary alloc] init];
[repeatDict setObject:[NSNumber numberWithInt:NSDayCalendarUnit] forKey:@"daily"]; [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitHour] forKey:@"hourly"];
[repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitDay] forKey:@"daily"];
[repeatDict setObject:[NSNumber numberWithInt:NSWeekCalendarUnit] forKey:@"weekly"]; [repeatDict setObject:[NSNumber numberWithInt:NSWeekCalendarUnit] forKey:@"weekly"];
[repeatDict setObject:[NSNumber numberWithInt:NSMonthCalendarUnit] forKey:@"monthly"]; [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitMonth] forKey:@"monthly"];
[repeatDict setObject:[NSNumber numberWithInt:NSYearCalendarUnit] forKey:@"yearly"]; [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitYear] forKey:@"yearly"];
[repeatDict setObject:[NSNumber numberWithInt:0] forKey:@""]; [repeatDict setObject:[NSNumber numberWithInt:0] forKey:@""];
return repeatDict; return repeatDict;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment