Sfoglia il codice sorgente

Added 'secondly' and 'minutely' as new repeat time aliases (Solves #102)

Sebastián Katzer 11 anni fa
parent
commit
208d13eab3
3 ha cambiato i file con 22 aggiunte e 13 eliminazioni
  1. 2 1
      README.md
  2. 5 1
      src/android/Options.java
  3. 15 11
      src/ios/APPLocalNotification.m

+ 2 - 1
README.md

@@ -54,6 +54,7 @@ More informations can be found [here](https://build.phonegap.com/plugins/413).
 - [bugfix:] cancel callbacks have not been fired after all notifications have been canceled on iOS.
 - [change:] The `oncancel` callback will be called at last if `autoCancel` is set to true (iOS).
 - [bugfix:] Callbacks for non-repeating notifications were not called if they were not created in the current app instance on iOS.
+- [enhancement:] Added 'secondly' and 'minutely' as new repeat time aliases.
 
 #### Version 0.7.2 (09.02.2014)
 - [enhancement:] Avoid blocking the main thread (on Android) **(dpogue)**.
@@ -141,7 +142,7 @@ window.plugin.notification.local.add({
     date:       Date,    // This expects a date object
     message:    String,  // The message that is displayed
     title:      String,  // The title of the message
-    repeat:     String,  // Has the options of 'hourly', 'daily', 'weekly', 'monthly', 'yearly'
+    repeat:     String,  // Has the options of 'secondly', 'minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly'
     badge:      Number,  // Displays number badge to notification
     sound:      String,  // A sound to be played
     json:       String,  // Data to be passed through the notification

+ 5 - 1
src/android/Options.java

@@ -58,7 +58,11 @@ public class Options {
 
         this.options = options;
 
-        if (repeat.equalsIgnoreCase("hourly")) {
+        if (repeat.equalsIgnoreCase("secondly")) {
+            interval = 1000;
+        } if (repeat.equalsIgnoreCase("minutely")) {
+            interval = AlarmManager.INTERVAL_FIFTEEN_MINUTES / 15;
+        } if (repeat.equalsIgnoreCase("hourly")) {
             interval = AlarmManager.INTERVAL_HOUR;
         } if (repeat.equalsIgnoreCase("daily")) {
             interval = AlarmManager.INTERVAL_DAY;

+ 15 - 11
src/ios/APPLocalNotification.m

@@ -199,20 +199,24 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
     NSMutableDictionary* repeatDict = [[NSMutableDictionary alloc] init];
 
 #ifdef NSCalendarUnitHour
-    [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:NSCalendarUnitMonth] forKey:@"monthly"];
-    [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitYear]  forKey:@"yearly"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitSecond] forKey:@"secondly"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitMinute] forKey:@"minutely"];
+    [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:NSCalendarUnitMonth]  forKey:@"monthly"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSCalendarUnitYear]   forKey:@"yearly"];
 #else
-    [repeatDict setObject:[NSNumber numberWithInt:NSHourCalendarUnit]  forKey:@"hourly"];
-    [repeatDict setObject:[NSNumber numberWithInt:NSDayCalendarUnit]   forKey:@"daily"];
-    [repeatDict setObject:[NSNumber numberWithInt:NSWeekCalendarUnit]  forKey:@"weekly"];
-    [repeatDict setObject:[NSNumber numberWithInt:NSMonthCalendarUnit] forKey:@"monthly"];
-    [repeatDict setObject:[NSNumber numberWithInt:NSYearCalendarUnit]  forKey:@"yearly"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSSecondCalendarUnit] forKey:@"secondly"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSMinuteCalendarUnit] forKey:@"minutely"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSHourCalendarUnit]   forKey:@"hourly"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSDayCalendarUnit]    forKey:@"daily"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSWeekCalendarUnit]   forKey:@"weekly"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSMonthCalendarUnit]  forKey:@"monthly"];
+    [repeatDict setObject:[NSNumber numberWithInt:NSYearCalendarUnit]   forKey:@"yearly"];
 #endif
 
-    [repeatDict setObject:[NSNumber numberWithInt:NSEraCalendarUnit]   forKey:@""];
+    [repeatDict setObject:[NSNumber numberWithInt:NSEraCalendarUnit]    forKey:@""];
 
     return repeatDict;
 }