Commit 1694a815 authored by PKnittel's avatar PKnittel
Browse files
parents 2d2ce205 9258d909
Loading
Loading
Loading
Loading
+2 −2
Changes for plugin.xml: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@
    </platform>

    <!-- wp8 -->
    <platform name="wp8">
<!--     <platform name="wp8">
        <config-file target="config.xml" parent="/*">
            <feature name="LocalNotification">
                <param name="wp-package" value="LocalNotification"/>
@@ -121,6 +121,6 @@

        <source-file src="src/wp8/LocalNotification.cs" />
        <source-file src="src/wp8/Options.cs" />
    </platform>
    </platform> -->

</plugin>
+2 −0
Changes for src/ios/APPLocalNotification.h: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@
- (void) deviceready:(CDVInvokedUrlCommand*)command;
// Schedule a new notification
- (void) add:(CDVInvokedUrlCommand*)command;
// Update a notification
- (void) update:(CDVInvokedUrlCommand*)command;
// Cancel a given notification
- (void) cancel:(CDVInvokedUrlCommand*)command;
// Cancel all currently scheduled notifications
+58 −16
Changes for src/ios/APPLocalNotification.m: 58 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@
    NSArray* notifications = command.arguments;

    [self.commandDelegate runInBackground:^{
        for (NSMutableDictionary* options in notifications) {
        for (NSDictionary* options in notifications) {
            UILocalNotification* notification;

            notification = [[UILocalNotification alloc]
@@ -90,6 +90,39 @@
    }];
}

/**
 * Update a set of notifications.
 *
 * @param properties
 *      A dict of properties for each notification
 */
- (void) update:(CDVInvokedUrlCommand*)command
{
    NSArray* notifications = command.arguments;

    [self.commandDelegate runInBackground:^{
        for (NSDictionary* options in notifications) {
            NSString* id = [options objectForKey:@"id"];
            UILocalNotification* notification;

            notification = [[UIApplication sharedApplication]
                            scheduledLocalNotificationWithId:id];

            if (!notification)
                continue;

            [self updateLocalNotification:[notification copy]
                              withOptions:options];

            if (notifications.count > 1) {
                [NSThread sleepForTimeInterval:0.01];
            }
        }

        [self execCallback:command];
    }];
}

/**
 * Cancel a set of notifications.
 *
@@ -335,14 +368,29 @@
     scheduleLocalNotification:notification];
}

/**
 * Update the local notification.
 */
- (void) updateLocalNotification:(UILocalNotification*)notification
                     withOptions:(NSDictionary*)newOptions
{
    NSMutableDictionary* options = [notification.userInfo mutableCopy];

    [options addEntriesFromDictionary:newOptions];
    [options setObject:[NSDate date] forKey:@"updatedAt"];

    notification = [[UILocalNotification alloc]
                    initWithOptions:options];

    [self scheduleLocalNotification:notification];

}

/**
 * Cancel the local notification.
 */
- (void) cancelLocalNotification:(UILocalNotification*)notification
{
    if (!notification)
        return;

    [[UIApplication sharedApplication]
     cancelLocalNotification:notification];

@@ -355,15 +403,6 @@
 */
- (void) cancelAllLocalNotifications
{
    NSArray* notifications;

    notifications = [[UIApplication sharedApplication]
                     scheduledLocalNotifications];

    for (UILocalNotification* notification in notifications) {
        [self cancelLocalNotification:notification];
    }

    [[UIApplication sharedApplication]
     cancelAllLocalNotifications];

@@ -401,7 +440,7 @@

    for (UILocalNotification* notification in notifications)
    {
        if (notification && notification.repeatInterval == NSCalendarUnitEra
        if (notification && [notification isRepeating]
            && notification.timeIntervalSinceFireDate > seconds)
        {
            [self cancelLocalNotification:notification];
@@ -421,8 +460,11 @@
{
    UILocalNotification* notification = [localNotification object];

    if ([notification wasUpdated])
        return;

    BOOL autoCancel = notification.options.autoCancel;
    NSTimeInterval timeInterval = notification.timeIntervalSinceFireDate;
    NSTimeInterval timeInterval = [notification timeIntervalSinceFireDate];

    NSString* event = (timeInterval <= 1 && deviceready) ? @"trigger" : @"click";

@@ -560,7 +602,7 @@
    if (notification) {
        NSString* id = notification.options.id;
        NSString* json = notification.options.json;
        NSString* args = [notification.options encodeToJSON];
        NSString* args = [notification encodeToJSON];

        params = [NSString stringWithFormat:
                  @"\"%@\",\"%@\",\\'%@\\',JSON.parse(\\'%@\\')",
+0 −2
Changes for src/ios/APPLocalNotificationOptions.h: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -33,8 +33,6 @@
@property (readonly, getter=repeatInterval) NSCalendarUnit repeatInterval;
@property (readonly, getter=userInfo) NSDictionary* userInfo;

// Encode the user info dict to JSON
- (NSString*) encodeToJSON;
// If it's a repeating notification
- (BOOL) isRepeating;

+0 −22
Changes for src/ios/APPLocalNotificationOptions.m: 0 added lines, 22 removed lines.
Original line number Diff line number Diff line
@@ -212,28 +212,6 @@
    return dict;
}

/**
 * Encode the user info dict to JSON.
 */
- (NSString*) encodeToJSON
{
    NSString* json;
    NSData* data;
    NSMutableDictionary* obj = [dict mutableCopy];

    [obj removeObjectForKey:@"json"];

    data = [NSJSONSerialization dataWithJSONObject:obj
                                           options:NSJSONWritingPrettyPrinted
                                             error:Nil];

    json = [[NSString alloc] initWithData:data
                                 encoding:NSUTF8StringEncoding];

    return [json stringByReplacingOccurrencesOfString:@"\n"
                                           withString:@""];
}

/**
 * If it's a repeating notification.
 */
Loading