Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- componentDidMount() {
- this.checkPermission();
- this.createNotificationListeners();
- }
- async createNotificationListeners() {
- this.notificationListener = firebase
- .notifications()
- .onNotification(notifications => {
- const { title, body } = notifications;
- const notification = new firebase.notifications.Notification()
- .setNotificationId("notificationId")
- .setTitle(title)
- .setBody(body)
- .android.setChannelId("channelId")
- .android.setSmallIcon("ic_launcher")
- .setSound("default");
- firebase.notifications().displayNotification(notification);
- this.props.setStatusInbox(true);
- });
- this.notificationOpenedListener = firebase
- .notifications()
- .onNotificationOpened(notificationOpen => {
- const { title, body } = notificationOpen.notification;
- const id = 138;
- this.props.navigation.navigate("DetailOrder", {
- id,
- onNavigateBack: () => this.refresh(),
- status: "notif"
- });
- // this.props.navigation.push("Inbox");
- console.log("notif", this.props);
- });
- const notificationOpen = await firebase
- .notifications()
- .getInitialNotification();
- if (notificationOpen) {
- const { title, body } = notificationOpen.notification;
- }
- this.messageListener = firebase.messaging().onMessage(message => {
- console.log(JSON.stringify(message));
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement