SHARE
TWEET

Untitled

a guest Jun 25th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top