Commit 8ccd6c3a authored by Libin Lu's avatar Libin Lu Committed by GitHub

Update README.md

parent febebf69
...@@ -129,10 +129,15 @@ pod install Firebase/Messaging ...@@ -129,10 +129,15 @@ pod install Firebase/Messaging
2. Follow the `README` to link frameworks (Analytics+Messaging) 2. Follow the `README` to link frameworks (Analytics+Messaging)
### Shared steps ### Shared steps
Edit `AppDelegate.h`:
```diff
+ @interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>
- @interface AppDelegate : UIResponder <UIApplicationDelegate>
```
Edit `AppDelegate.m`: Edit `AppDelegate.m`:
```diff ```diff
+ #import "Firebase.h" // if you are using Non Cocoapod approach + @import FirebaseAnalytics;
+ #import "RNFIRMessaging.h" + #import "RNFIRMessaging.h"
//... //...
...@@ -140,12 +145,32 @@ Edit `AppDelegate.m`: ...@@ -140,12 +145,32 @@ Edit `AppDelegate.m`:
{ {
//... //...
+ [FIRApp configure]; + [FIRApp configure];
+ #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
+ [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
+ #endif
} }
+ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler { + #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
+ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification]; + - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification + + withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
+ handler(UIBackgroundFetchResultNewData); + {
+ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.request.content.userInfo];
+ completionHandler(UNNotificationPresentationOptionAlert);
+ }
+ - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler
+ {
+ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:response.notification.request.content.userInfo];
+ }
+ #else
+ -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
+ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self + userInfo:notification.userInfo];
+ }
+
+ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
+ [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo];
+ completionHandler(UIBackgroundFetchResultNoData);
+ } + }
+ #endif
``` ```
### FCM config file ### FCM config file
......
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