From 8581e1b5ce944cfd0bd240aab1ae455464bcf07c Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 8 Aug 2019 11:20:28 -0700 Subject: [PATCH] Messaging: Convert from var to const (#354) * update firebase SDK version in service worker * Convert from var to const for consistency --- .eslintrc.json | 3 +++ messaging/firebase-messaging-sw.js | 6 +++--- messaging/index.html | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index cf23c7d40..e7f327b86 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,7 @@ { + "parserOptions": { + "ecmaVersion": 2017 + }, "env": { "browser": true }, diff --git a/messaging/firebase-messaging-sw.js b/messaging/firebase-messaging-sw.js index 91e3ca668..ca838aa7c 100644 --- a/messaging/firebase-messaging-sw.js +++ b/messaging/firebase-messaging-sw.js @@ -5,7 +5,7 @@ importScripts('/__/firebase/6.3.4/firebase-app.js'); importScripts('/__/firebase/6.3.4/firebase-messaging.js'); importScripts('/__/firebase/init.js'); -var messaging = firebase.messaging(); +const messaging = firebase.messaging(); /** * Here is is the code snippet to initialize Firebase Messaging in the Service @@ -38,8 +38,8 @@ var messaging = firebase.messaging(); messaging.setBackgroundMessageHandler(function(payload) { console.log('[firebase-messaging-sw.js] Received background message ', payload); // Customize notification here - var notificationTitle = 'Background Message Title'; - var notificationOptions = { + const notificationTitle = 'Background Message Title'; + const notificationOptions = { body: 'Background Message body.', icon: '/firebase-logo.png' }; diff --git a/messaging/index.html b/messaging/index.html index b12ef34fb..9a1f12a52 100644 --- a/messaging/index.html +++ b/messaging/index.html @@ -156,7 +156,7 @@

Needs Permission

function showToken(currentToken) { // Show token in console and UI. - var tokenElement = document.querySelector('#token'); + const tokenElement = document.querySelector('#token'); tokenElement.textContent = currentToken; }