SHARE
TWEET

firebase-messaging-sw.js

michussj07 Dec 28th, 2018 7 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. importScripts('https://www.gstatic.com/firebase/5.7,1/firebase-app.js');
  3. importScripts('https://www.gstatic.com/firebase/5.7.1/firebase-messaging.js');
  4.  
  5.   var config = {
  6.     apiKey: "AIzaSyDZ56QKkFT33hC3Ee3KyhqwkM0Pmkysg20",
  7.     authDomain: "push-v2-7a3d4.firebaseapp.com",
  8.     databaseURL: "https://push-v2-7a3d4.firebaseio.com",
  9.     projectId: "push-v2-7a3d4",
  10.     storageBucket: "",
  11.     messagingSenderId: "335978700030"
  12.   };
  13.   firebase.initializeApp(config);
  14.  
  15. const messaging = firebase.messaging();
  16.  
  17.  
  18. messaging.setBackgroundMessageHandler(function(payload) {
  19.   console.log('[firebase-messaging-sw.js] Received background message ', payload);
  20.  
  21.   const notificationTitle = 'Background Message Title';
  22.   const notificationOptions = {
  23.     body: 'Background Message body.',
  24.     icon: '/firebase-logo.png'
  25.   };
  26.  
  27.   return self.registration.showNotification(notificationTitle,
  28.     notificationOptions);
  29. });
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
 
Top