-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathfirebase-messaging-sw.php
More file actions
23 lines (21 loc) · 961 Bytes
/
firebase-messaging-sw.php
File metadata and controls
23 lines (21 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
header('Content-Type: application/javascript');
$init_skip_csrfp = true;
require_once "init_without_validate.php";
?>
// 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/10.7.1/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/10.7.1/firebase-messaging-compat.js');
// Initialize the Firebase app in the service worker by passing in the
// messagingSenderId.
firebase.initializeApp({
'messagingSenderId': '<?php echo $CFG['FCM']['SenderId']; ?>',
'apiKey': '<?php echo $CFG['FCM']['webApiKey']; ?>',
'projectId': '<?php echo $CFG['FCM']['project_id']; ?>',
'appId': '<?php echo $CFG['FCM']['app_id']; ?>'
});
// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();