This file contains hidden or 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
self.addEventListener('push', async(e) => { | |
const notification = await fetch(e.data.text()); // payload contains a URL | |
await registration.showNotification(notification.title, { | |
body: notification.body, | |
icon: notification.icon | |
}); | |
}); |
This file contains hidden or 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
diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc | |
index 2543d79d..ffa3179 100644 | |
--- a/chrome/browser/push_messaging/push_messaging_browsertest.cc | |
+++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc | |
@@ -901,6 +901,8 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | |
HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | |
->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING); | |
+ HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | |
+ ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
This file contains hidden or 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
diff --git a/chrome/browser/push_messaging/push_messaging_permission_context.cc b/chrome/browser/push_messaging/push_messaging_permission_context.cc | |
index 6125f3e..bd774dd 100644 | |
--- a/chrome/browser/push_messaging/push_messaging_permission_context.cc | |
+++ b/chrome/browser/push_messaging/push_messaging_permission_context.cc | |
@@ -53,12 +53,11 @@ ContentSetting PushMessagingPermissionContext::GetPermissionStatus( | |
push_content_setting == CONTENT_SETTING_BLOCK) { | |
return CONTENT_SETTING_BLOCK; | |
} | |
- if (notifications_permission == CONTENT_SETTING_ASK || | |
- push_content_setting == CONTENT_SETTING_ASK) { |
This file contains hidden or 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
navigator.serviceWorker.ready.then(registration => { | |
// Note that userVisibleOnly is not required for payloads - it's (still) | |
// required for Chrome's implementation though. | |
registration.pushManager.subscribe({ userVisibleOnly: true }).then(subscription => { | |
// Option 1: Using JSON.stringify() (recommended). | |
// | |
// The created JSON will have the following structure: | |
// { "endpoint": "https://...", | |
// "keys": { | |
// "p256dh": "...", // base64url encoded uncompressed P-256 EC point |