From 0d569b840311a4f14e0c0daf6154b4b815237527 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Fri, 7 Oct 2016 15:36:51 -0400 Subject: [PATCH] Update README.md --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7790ea7..6ad3f94 100644 --- a/README.md +++ b/README.md @@ -158,12 +158,19 @@ Edit `AppDelegate.m`: + - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler + { + [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.request.content.userInfo]; -+ completionHandler(UNNotificationPresentationOptionAlert); ++ if([notification.request.content.userInfo valueForKey:@"show_in_foreground"]){ ++ completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound); ++ }else{ ++ completionHandler(UNNotificationPresentationOptionNone); ++ } + + } + - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler + { -+ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:response.notification.request.content.userInfo]; ++ NSDictionary* userInfo = [[NSMutableDictionary alloc] initWithDictionary: response.notification.request.content.userInfo]; ++ [userInfo setValue:@YES forKey:@"opened_from_tray"]; ++ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo]; + } + #else + //You can skip this method if you don't want to use local notification -- 2.26.2