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

Better way to find out if a notification was triggered or clicked

parent 6abf363a
Loading
Loading
Loading
Loading
+4 −1
Changes for src/ios/APPLocalNotification.m: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -244,13 +244,16 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
{
    UIApplicationState state          = [[UIApplication sharedApplication] applicationState];
    bool isActive                     = state == UIApplicationStateActive;
    NSString* event                   = isActive ? @"trigger" : @"click";

    UILocalNotification* notification = [localNotification object];
    NSString* id                      = [notification.userInfo objectForKey:@"id"];
    NSString* json                    = [notification.userInfo objectForKey:@"json"];
    BOOL autoCancel                   = [[notification.userInfo objectForKey:@"autoCancel"] boolValue];

    NSDate* now                       = [NSDate date];
    NSTimeInterval fireDateDistance   = [now timeIntervalSinceDate:notification.fireDate];
    NSString* event                   = (fireDateDistance < 0.01) ? @"trigger" : @"click";

    if (autoCancel && !isActive)
    {
        [self cancelNotificationWithId:id];