{"size": 1190, "ext": "js", "max_stars_repo_path": "static/firebase-messaging-sw.js", "max_stars_repo_name": "oriolcastro/6by6challenge-january", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "static/firebase-messaging-sw.js", "max_issues_repo_name": "oriolcastro/6by6challenge-january", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "static/firebase-messaging-sw.js", "max_forks_repo_name": "oriolcastro/6by6challenge-january", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.75, "max_line_length": 79, "alphanum_fraction": 0.7521008403}
/* eslint-disable */

// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here, other Firebase libraries
// are not available in the service worker.
importScripts('https://www.gstatic.com/firebasejs/5.4.2/firebase-app.js')
importScripts('https://www.gstatic.com/firebasejs/5.4.2/firebase-messaging.js')

// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
  messagingSenderId: '940834189237',
})

// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging()

messaging.setBackgroundMessageHandler(function(payload) {
  console.log(
    '[firebase-messaging-sw.js] Received background message ',
    payload
  )

  const notification = payload.data.notification
  const { title, body, click_action } = JSON.parse(notification)
  // Customize notification here
  const notificationTitle = title
  const notificationOptions = {
    body: body,
    icon: '/icon.png',
    click_action: click_action,
  }

  return self.registration.showNotification(
    notificationTitle,
    notificationOptions
  )
})
