-
Notifications
You must be signed in to change notification settings - Fork 20
/
service_worker.js
29 lines (28 loc) · 988 Bytes
/
service_worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
importScripts("./cross_context.js");
(async () => {
try {
await chrome.offscreen.closeDocument()
console.log("existing offscreen document closed");
} catch (error) {
console.log("no offscreen document to close")
}
try {
const result = await chrome.offscreen.createDocument({
url: 'join.html',
reasons: ['CLIPBOARD', 'LOCAL_STORAGE'],
justification: 'reason for needing the document',
});
console.log('Offscreen document created successfully:', result);
} catch (error) {
console.warn('Error creating offscreen document:', error);
}
})();
chrome.gcm.onMessage.addListener(payload => {
console.log("Received gcm in service worker", payload)
});
chrome.notifications.onClicked.addListener(id => {
console.log("Notification clicked", id)
})
chrome.notifications.onButtonClicked.addListener((id, index) => {
console.log("Notification button clicked", id, index)
})