diff --git a/README.md b/README.md index 3f0d0ff460afed4a5edc6d280e2c937dee0266fd..14d1961a8d661b82fd9140ddfe7d6efafe2051a8 100644 --- a/README.md +++ b/README.md @@ -172,12 +172,9 @@ Edit `AppDelegate.m`: { //... + [FIRApp configure]; -+ #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 + [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; -+ #endif - } - -+ #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 ++ } ++ + - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler + { + [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.request.content.userInfo]; @@ -186,21 +183,20 @@ Edit `AppDelegate.m`: + }else{ + completionHandler(UNNotificationPresentationOptionNone); + } - ++ + } - ++ + - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler + { + 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 + -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { + [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self + userInfo:notification.userInfo]; + } -+ #endif + + - (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{ + [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo];