Commit 0d569b84 authored by Libin Lu's avatar Libin Lu Committed by GitHub

Update README.md

parent f6321172
......@@ -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
......
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