Created
January 12, 2021 13:04
-
-
Save Karthik-B-06/af0c5360727024186ad175e7eb165539 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| useEffect(() => { | |
| // When notification is received in foreground | |
| messaging().onMessage((remoteMessage) => { | |
| Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage)); | |
| }); | |
| // When an app is opened through notification | |
| messaging().onNotificationOpenedApp((remoteMessage) => { | |
| console.log('Notification caused app to open from background state:', remoteMessage.notification); | |
| }); | |
| // Check whether an initial notification is available | |
| messaging() | |
| .getInitialNotification() | |
| .then((remoteMessage) => { | |
| if (remoteMessage) { | |
| console.log('Notification caused app to open from quit state:', remoteMessage.notification); | |
| } | |
| }) | |
| .finally(() => null); | |
| }, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment