Commit 3ca2de8c by Sebastián Katzer

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

parent 6abf363a
...@@ -244,13 +244,16 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION"; ...@@ -244,13 +244,16 @@ NSString *const kAPP_LOCALNOTIFICATION = @"APP_LOCALNOTIFICATION";
{ {
UIApplicationState state = [[UIApplication sharedApplication] applicationState]; UIApplicationState state = [[UIApplication sharedApplication] applicationState];
bool isActive = state == UIApplicationStateActive; bool isActive = state == UIApplicationStateActive;
NSString* event = isActive ? @"trigger" : @"click";
UILocalNotification* notification = [localNotification object]; UILocalNotification* notification = [localNotification object];
NSString* id = [notification.userInfo objectForKey:@"id"]; NSString* id = [notification.userInfo objectForKey:@"id"];
NSString* json = [notification.userInfo objectForKey:@"json"]; NSString* json = [notification.userInfo objectForKey:@"json"];
BOOL autoCancel = [[notification.userInfo objectForKey:@"autoCancel"] boolValue]; 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) if (autoCancel && !isActive)
{ {
[self cancelNotificationWithId:id]; [self cancelNotificationWithId:id];
......
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