Commit 2b0c24f0 authored by Libin Lu's avatar Libin Lu Committed by GitHub

Update README.md

parent 465347be
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
## NOTE: ## NOTE:
- If you are running RN < 0.30.0, you need to use react-native-fcm@1.0.15 - If you are running RN < 0.30.0, you need to use react-native-fcm@1.0.15
- If you are running RN < 0.33.0, you need to user react-native-fcm@1.1.0 - If you are running RN < 0.33.0, you need to user react-native-fcm@1.1.0
- Otherwise use latest v2
## Installation ## Installation
...@@ -200,9 +201,12 @@ class App extends Component { ...@@ -200,9 +201,12 @@ class App extends Component {
}); });
this.notificationUnsubscribe = FCM.on('notification', (notif) => { this.notificationUnsubscribe = FCM.on('notification', (notif) => {
// there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload // there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload
}); if(notif.local_notification){
this.localNotificationUnsubscribe = FCM.on('localNotification', (notif) => { //this is a local notification
// notif.notification contains the data }
if(notif.opened_from_tray){
//app is open/resumed because user clicked banner
}
}); });
this.refreshUnsubscribe = FCM.on('refreshToken', (token) => { this.refreshUnsubscribe = FCM.on('refreshToken', (token) => {
console.log(token) console.log(token)
...@@ -214,7 +218,6 @@ class App extends Component { ...@@ -214,7 +218,6 @@ class App extends Component {
// prevent leaking // prevent leaking
this.refreshUnsubscribe(); this.refreshUnsubscribe();
this.notificationUnsubscribe(); this.notificationUnsubscribe();
this.localNotificationUnsubscribe();
} }
otherMethods(){ otherMethods(){
...@@ -361,6 +364,18 @@ You can either wait for FCM to develop it or you have to write native code to cr ...@@ -361,6 +364,18 @@ You can either wait for FCM to develop it or you have to write native code to cr
Or if you have a good way to wake up react native javascript thread please let me know, although I'm worring waking up the whole application is too expensive. Or if you have a good way to wake up react native javascript thread please let me know, although I'm worring waking up the whole application is too expensive.
#### What about new notifications in iOS 10
Congratulations, now you have 5 notification handler to register!
in sum
- `willPresentNotification` is introduced in iOS 10 and will only be called when local/remote notification will show up. This allows you to run some code **before** notification shows up. You can also decide how to show the notification.
- `didReceiveNotificationResponse` is introduced in iOS 10 and provides user's response together with local/remote notification. It could be swipe, text input etc.
- `didReceiveLocalNotification` is for iOS 9 and below. Triggered when user clicks local notification. replaced by `didReceiveNotificationResponse`
- `didReceiveRemoteNotification` is for iOS 9 and below. Triggered when remote notification received.
- `didReceiveRemoteNotification:fetchCompletionHandler` is for both iOS 9 and 10. it gets triggered 2 times for each remote notification. 1st time when notification is received. 2nd time when notification is clicked. in iOS 9, it serves us the purpose of both `willPresentNotification` and `didReceiveNotificationResponse` but for remote notification only. in iOS 10, you don't need it in most of the case unless you need to do background fetching
Great, how do I configure for FCM?
It is up to you! FCM is just a bridging library that passes notification into javascript world. You can define your own NSDictionary and pass it into notification.
#### Some features are missing #### Some features are missing
Issues and pull requests are welcome. Let's make this thing better! Issues and pull requests are welcome. Let's make this thing better!
......
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