This repository has been archived by the owner on Sep 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
396 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var messageChannel; | ||
|
||
self.addEventListener('install', function(event) { | ||
self.skipWaiting(); | ||
}); | ||
|
||
self.addEventListener('push', function(event) { | ||
// parse incoming message | ||
var obj = {}; | ||
if (event.data) { | ||
obj = event.data.json(); | ||
} | ||
|
||
// Need to figure out a way to make these configurable | ||
var title = obj.title || 'Default title'; | ||
var body = obj.body || 'This is the default body'; | ||
var icon = 'https://avatars1.githubusercontent.com/u/60365?v=3&s=200'; | ||
var tag = 'simple-push-demo-notification-tag'; | ||
|
||
event.waitUntil( | ||
self.registration.showNotification(title, { | ||
body: body, | ||
icon: icon, | ||
tag: tag | ||
}) | ||
); | ||
|
||
var pushData = { | ||
title: title, | ||
message: body, | ||
count: 1, | ||
sound: 'default', | ||
additionalData: {} | ||
}; | ||
messageChannel.ports[0].postMessage(pushData); | ||
|
||
}); | ||
|
||
self.addEventListener('message', function(event) { | ||
messageChannel = event; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "Push Demo", | ||
"gcm_sender_id": "85075801930" | ||
} |
Oops, something went wrong.