importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-app.js');
importScripts('firebase-messaging.js');

var config = {
    messagingSenderId: "998157547773"
};
firebase.initializeApp(config);
//
var messaging = firebase.messaging();

messaging.setBackgroundMessageHandler(function (payload) {
    // Customize notification here
    notificationTitle = payload.data.title,
            notificationOptions = {
                body: payload.data.body,
                icon: payload.data.icon
            };
    var notification = new Notification(notificationTitle, notificationOptions);
    $(".target").append("<p>" + notificationTitle + "<br>" + payload.data.body + "</p>");
});