Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Issue #1199: iOS 10 is not firing the 'notification' event after clic…
Browse files Browse the repository at this point in the history
…king on a notification when the app is in hibernate
  • Loading branch information
macdonst committed Sep 14, 2016
1 parent 1fe6406 commit e711b09
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ios/AppDelegate+notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotif
[pushHandler didFailToRegisterForRemoteNotificationsWithError:error];
}

- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"clicked on the shade");
PushPlugin *pushHandler = [self getCommandInstance:@"PushNotification"];
pushHandler.notificationMessage = userInfo;
pushHandler.isInline = NO;
[pushHandler notificationReceived];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSLog(@"didReceiveNotification with fetchCompletionHandler");

Expand Down

4 comments on commit e711b09

@menelike
Copy link

@menelike menelike commented on e711b09 Nov 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this works, in my case this event never fires, no matter what.

Implement the application:didReceiveRemoteNotification:fetchCompletionHandler: method instead of this one whenever possible. If your delegate implements both methods, the app object calls the application:didReceiveRemoteNotification:fetchCompletionHandler: method.

https://developer.apple.com/reference/uikit/uiapplicationdelegate/1623117-application?language=objc

I understand: since application:didReceiveRemoteNotification:fetchCompletionHandler is also defined, the code above will never fire.

Distinguishing between user clickedand notification received is hard to solve, I can't find a simple way to fix this.

But https://github.com/fechanique/cordova-plugin-fcm/blob/53bd6bfd38320b2b8025604352fb5882ec3bb7ae/src/ios/AppDelegate%2BFCMPlugin.m uses this as well, not sure about this.

@djett41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@menelike did you figure this out? Im seeing the same behavior after upgrading to Cordova 6.5.0 along with this plugin. I tried Lucklyrick's fork but no luck

@menelike
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djett41 sorry, it's been a while and I can not remember how we solved this case

You may try https://github.com/risetechnologies/phonegap-plugin-push/tree/tappedFixiOS at your own risk (we added some undocumented features). I think that risetechnologies@5b54836 was related to this issue, hope it helps

@djett41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the reply @menelike !! I'm actually using a fork by intercom for push notifications and they bypass most of the logic from your commit thats adds the tapped property if the push notification comes from intercom.. so im not sure if this will work, but I just put in an issue for them as it could possibly be a payload issue on their part

Please sign in to comment.