Commit f43aa60d authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

Fix handling notifications when application process has been killed #87

parent 78bb3e81
Loading
Loading
Loading
Loading
+2 −1
Changes for plugin.xml: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@
    <platform name="ios">
        <config-file target="config.xml" parent="/*">
            <feature name="LocalNotification">
                <param name="ios-package" value="APPLocalNotification"/>
                <param name="ios-package" value="APPLocalNotification" onload="true" />
                <param name="onload" value="true" />
            </feature>
        </config-file>

+21 −1
Changes for src/ios/APPLocalNotification.m: 21 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@
- (UILocalNotification*) notificationWithProperties:(NSMutableDictionary*)options;
// Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist
- (void) didReceiveLocalNotification:(NSNotification*)localNotification;
// Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist
- (void) didFinishLaunchingWithOptions:(NSNotification*)notification;
// Hilfsmethode gibt an, ob er String NULL oder Empty ist
- (BOOL) strIsNullOrEmpty:(NSString*)str;
// Fires the given event
@@ -300,12 +302,30 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
    }
}

/**
 * Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist.
 */
- (void) didFinishLaunchingWithOptions:(NSNotification*)notification
{
    NSDictionary* launchOptions            = [notification userInfo];
    UILocalNotification *localNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

    if (localNotification)
    {
        [self didReceiveLocalNotification:notification];
    }
}

/**
 * Registriert den Observer für LocalNotification Events.
 */
- (void) pluginInitialize
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:)
                                                 name:CDVLocalNotification object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishLaunchingWithOptions:)
                                                 name:UIApplicationDidFinishLaunchingNotification object:nil];
}

/**