Advertisement
Guest User

splashScreen.js

a guest
Mar 26th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. componentDidMount() {
  3. this.checkPermission();
  4. this.createNotificationListeners();
  5. }
  6.  
  7. async createNotificationListeners() {
  8. this.notificationListener = firebase
  9. .notifications()
  10. .onNotification(notifications => {
  11. const { title, body } = notifications;
  12.  
  13. const notification = new firebase.notifications.Notification()
  14. .setNotificationId("notificationId")
  15. .setTitle(title)
  16. .setBody(body)
  17. .android.setChannelId("channelId")
  18. .android.setSmallIcon("ic_launcher")
  19. .setSound("default");
  20.  
  21. firebase.notifications().displayNotification(notification);
  22.  
  23. this.props.setStatusInbox(true);
  24. });
  25.  
  26. this.notificationOpenedListener = firebase
  27. .notifications()
  28. .onNotificationOpened(notificationOpen => {
  29. const { title, body } = notificationOpen.notification;
  30. const id = 138;
  31.  
  32. this.props.navigation.navigate("DetailOrder", {
  33. id,
  34. onNavigateBack: () => this.refresh(),
  35. status: "notif"
  36. });
  37. // this.props.navigation.push("Inbox");
  38. console.log("notif", this.props);
  39. });
  40.  
  41. const notificationOpen = await firebase
  42. .notifications()
  43. .getInitialNotification();
  44. if (notificationOpen) {
  45. const { title, body } = notificationOpen.notification;
  46. }
  47.  
  48. this.messageListener = firebase.messaging().onMessage(message => {
  49. console.log(JSON.stringify(message));
  50. });
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement