Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. // firebase-messaging-sw.js
  2. ....
  3. messaging.setBackgroundMessageHandler(function(payload) {
  4. console.log('[firebase-messaging-sw.js] Received background message ', payload);
  5. // Customize notification here
  6. let notificationTitle = 'Background Message Title';
  7. let notificationOptions = {
  8. body: 'Background Message body.',
  9. icon: 'resource/icon_web.png'
  10. };
  11.  
  12. return self.registration.showNotification(notificationTitle, notificationOptions);
  13. });
  14.  
  15. // popup.js
  16. firebase.initializeApp(config);
  17. const messaging = firebase.messaging();
  18. messaging.onMessage(function (payload) {
  19. console.log('Message received. ', payload);
  20. });
  21.  
  22. [firebase-messaging-sw.js] Received background message
  23. {data: {…}, from: "153493200810", collapse_key: "do_not_collapse"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement