Meet Web Push for Safari

RSS for tag

Discuss the WWDC22 Session Meet Web Push for Safari

Posts under wwdc2022-10098 tag

9 Posts

Post

Replies

Boosts

Views

Activity

Does Web Push Notification Actions work on iOS 16.4 ?
I managed to get my Progressive Web App to send notifications to users via Web Push. However, it seems that the definable actions are not working. In Chrome, there is a button in the notification. If you click it, you get an overview of the available actions that the user can click. When I look at the notification on iOS, I only see the "View" action. My self-defined actions seem to be ignored and not displayed. Also, the "notificationclick" event should be executed by the browser as soon as the notification is clicked. In the Serviceworker I listened to the event and tried to link to a specific page of the PWA. In Chrome and Firefox this works fine. In Safari / iOS I only get to the start page of the PWA. Are the notification actions not yet supported with WebKit 16.4 ?
9
2
5.4k
Sep ’23
On safari 16, web push notifications are not receiving after 3 messages.
I have implemented the web push notifications using the FCM, the thing is I am getting the notifications on safari(but count is only 3 and it varies some time to 4-6). I know that safari will revoke the notification permission, if we do not send the notification to notification center. But in my case I am already sending the notification to notification center, and and it displays the notification on screen(up right corner), after that also it revokes the permission. Is their specific we need to handle in case of service worker ? that user have to mandatory open the notifications upon receiving otherwise it will revoke the permission. Do we have any sample code specific for web push notifications (not local notifications), on how to handle the background messages(through service workers), and the foreground messages(when tab is active). In case of tab active(generally onMessage), I am showing the notification using the following code : let notification = new Notification('title', { 'body': 'some test body' }); And in case of background message(service worker is handling it, specifically I am not doing any thing to show the notification). My service worker code : importScripts("https://www.gstatic.com/firebasejs/9.20.0/firebase-app-compat.js"); importScripts("https://www.gstatic.com/firebasejs/9.20.0/firebase-messaging-compat.js"); self.addEventListener('notificationclick', (event) => { console.log("background worker trigger"); event.notification.close() const pathname = event.notification?.data?.FCM_MSG?.data?.link if (!pathname) return const url = new URL(pathname, self.location.origin).href event.waitUntil( self.clients .matchAll({ type: 'window', includeUncontrolled: true }) .then((clientsArr) => { const hadWindowToFocus = clientsArr.some((windowClient) => windowClient.url === url ? (windowClient.focus(), true) : false ) if (!hadWindowToFocus) self.clients .openWindow(url) .then((windowClient) => //windowClient ? windowClient.focus() : null console.log("opened window") ) }) ) }) if (!firebase.apps.length) { firebase.initializeApp({ apiKey: "somekey", authDomain: "somekey", projectId: "somekey", storageBucket: "somekey", messagingSenderId: "somekey", appId: "somekey", vapidKey: 'somekey' }); } else { firebase.app(); // if already initialized, use that one } const messaging = firebase.messaging(); messaging.onBackgroundMessage(function(payload) { console.log('[firebase-messaging-sw.js] Received background message ', payload); })
1
0
1.9k
Aug ’23
iOS web push navigates to a blank screen after clicking the 'Done' button
Steps to recreate the bug Add to home screen and subscribe to the web push Close the PWA (this is an important step if you have the PWA open this bug won't happen) Then send a push notification to the PWA You will get push notification everything will be fine till here There will "Done" button at the top left. Click on it it will result in a blank screen If you had the PWA open "Done" button will navigate back to the PWA. How do you make sure the links open inside PWA or hide the "Done" button or make sure clicking on "Done" navigates back to the PWA This seems to be happening in iOS web push 16.4.1 and 16.5 beta
2
0
1.3k
Apr ’23
Sending Push Notifications to Safari from Java
Hello all! I am trying to get the Web Push API to work with my app and Safari on iOS. I can register fine in Safari ... But, when trying to send my request to the endpoint I receive a 403 with reason: BadJwtToken. I've verified the token being sent in the Authentication header is valid. Also, the code I am using to send the Push request works perfectly on Chrome & Edge. Has anyone else experienced this behaviour? Any suggestions would be greatly appreciated.
1
0
2.0k
Feb ’23
Safari 16 Preview: ServiceWorkerRegistration.pushManager undefined
I was led to understand that the Web Push API is available in the Safari 16 Preview. I have Web Push notifications working fine in Chrome and Firefox, using the methods described in the video at https://developer.apple.com/videos/play/wwdc2022/10098/ However, when it comes to asking the user for permission and creating a subscription using the Safari 16 Technology Preview, this fails as ServiceWorkerRegistration.pushManager is undefined.
2
0
2.9k
Jan ’23
Web Push response is always success, even if subscription no longer valid
If a user is subscribed to Push API (not the old Apple only push notifications), but then blocks notifications in safari settings or system preferences, the endpoint is still valid. The response from the server that sends the push notification should be 40* if the subscription is no longer valid. this allows the server to remove that subscription However on safari it is always valid, causing a build up of expired/unused subscription endpoints which must still be called in case they are valid. To re-create: subscribe to user notifications in safari settings, set to the domain's notification settings to deny trigger push notification on server. it's response will still be 200 even though the subscription is now invalid
1
1
1.3k
Nov ’22
Web Push and Push notifications
Apple recently introduced and presented Web Push, a new Web Kit tool permitting to send notifications to users on your websites and web apps. However, push notifications have been a thing on macOS since Mavericks. Therefore, what is the difference between these two things ?(https://developer.apple.com/notifications/safari-push-notifications/ ) and that new thing (https://developer.apple.com/videos/play/wwdc2022/10098/)
2
1
2.5k
Aug ’22
Does Web Push Notification Actions work on iOS 16.4 ?
I managed to get my Progressive Web App to send notifications to users via Web Push. However, it seems that the definable actions are not working. In Chrome, there is a button in the notification. If you click it, you get an overview of the available actions that the user can click. When I look at the notification on iOS, I only see the "View" action. My self-defined actions seem to be ignored and not displayed. Also, the "notificationclick" event should be executed by the browser as soon as the notification is clicked. In the Serviceworker I listened to the event and tried to link to a specific page of the PWA. In Chrome and Firefox this works fine. In Safari / iOS I only get to the start page of the PWA. Are the notification actions not yet supported with WebKit 16.4 ?
Replies
9
Boosts
2
Views
5.4k
Activity
Sep ’23
On safari 16, web push notifications are not receiving after 3 messages.
I have implemented the web push notifications using the FCM, the thing is I am getting the notifications on safari(but count is only 3 and it varies some time to 4-6). I know that safari will revoke the notification permission, if we do not send the notification to notification center. But in my case I am already sending the notification to notification center, and and it displays the notification on screen(up right corner), after that also it revokes the permission. Is their specific we need to handle in case of service worker ? that user have to mandatory open the notifications upon receiving otherwise it will revoke the permission. Do we have any sample code specific for web push notifications (not local notifications), on how to handle the background messages(through service workers), and the foreground messages(when tab is active). In case of tab active(generally onMessage), I am showing the notification using the following code : let notification = new Notification('title', { 'body': 'some test body' }); And in case of background message(service worker is handling it, specifically I am not doing any thing to show the notification). My service worker code : importScripts("https://www.gstatic.com/firebasejs/9.20.0/firebase-app-compat.js"); importScripts("https://www.gstatic.com/firebasejs/9.20.0/firebase-messaging-compat.js"); self.addEventListener('notificationclick', (event) => { console.log("background worker trigger"); event.notification.close() const pathname = event.notification?.data?.FCM_MSG?.data?.link if (!pathname) return const url = new URL(pathname, self.location.origin).href event.waitUntil( self.clients .matchAll({ type: 'window', includeUncontrolled: true }) .then((clientsArr) => { const hadWindowToFocus = clientsArr.some((windowClient) => windowClient.url === url ? (windowClient.focus(), true) : false ) if (!hadWindowToFocus) self.clients .openWindow(url) .then((windowClient) => //windowClient ? windowClient.focus() : null console.log("opened window") ) }) ) }) if (!firebase.apps.length) { firebase.initializeApp({ apiKey: "somekey", authDomain: "somekey", projectId: "somekey", storageBucket: "somekey", messagingSenderId: "somekey", appId: "somekey", vapidKey: 'somekey' }); } else { firebase.app(); // if already initialized, use that one } const messaging = firebase.messaging(); messaging.onBackgroundMessage(function(payload) { console.log('[firebase-messaging-sw.js] Received background message ', payload); })
Replies
1
Boosts
0
Views
1.9k
Activity
Aug ’23
iOS web push navigates to a blank screen after clicking the 'Done' button
Steps to recreate the bug Add to home screen and subscribe to the web push Close the PWA (this is an important step if you have the PWA open this bug won't happen) Then send a push notification to the PWA You will get push notification everything will be fine till here There will "Done" button at the top left. Click on it it will result in a blank screen If you had the PWA open "Done" button will navigate back to the PWA. How do you make sure the links open inside PWA or hide the "Done" button or make sure clicking on "Done" navigates back to the PWA This seems to be happening in iOS web push 16.4.1 and 16.5 beta
Replies
2
Boosts
0
Views
1.3k
Activity
Apr ’23
Sending Push Notifications to Safari from Java
Hello all! I am trying to get the Web Push API to work with my app and Safari on iOS. I can register fine in Safari ... But, when trying to send my request to the endpoint I receive a 403 with reason: BadJwtToken. I've verified the token being sent in the Authentication header is valid. Also, the code I am using to send the Push request works perfectly on Chrome & Edge. Has anyone else experienced this behaviour? Any suggestions would be greatly appreciated.
Replies
1
Boosts
0
Views
2.0k
Activity
Feb ’23
Safari 16 Preview: ServiceWorkerRegistration.pushManager undefined
I was led to understand that the Web Push API is available in the Safari 16 Preview. I have Web Push notifications working fine in Chrome and Firefox, using the methods described in the video at https://developer.apple.com/videos/play/wwdc2022/10098/ However, when it comes to asking the user for permission and creating a subscription using the Safari 16 Technology Preview, this fails as ServiceWorkerRegistration.pushManager is undefined.
Replies
2
Boosts
0
Views
2.9k
Activity
Jan ’23
Safari 16 TP 151 : Push API error: AbortError: No connection to push daemon
It appears that the Safari 16 Technology Preview is not fully functional as shown in the WWDC video. When attempting to get the user permission and the subscription object, the subscribe(..) method fails with : AbortError: No connection to push daemon https://developer.apple.com/videos/play/wwdc2022/10098/
Replies
2
Boosts
2
Views
1.7k
Activity
Dec ’22
Web Push on Safari 16
Hey evreybody, can pass image and additional buttons to my push notification on my website oon Safari 16?
Replies
0
Boosts
0
Views
883
Activity
Nov ’22
Web Push response is always success, even if subscription no longer valid
If a user is subscribed to Push API (not the old Apple only push notifications), but then blocks notifications in safari settings or system preferences, the endpoint is still valid. The response from the server that sends the push notification should be 40* if the subscription is no longer valid. this allows the server to remove that subscription However on safari it is always valid, causing a build up of expired/unused subscription endpoints which must still be called in case they are valid. To re-create: subscribe to user notifications in safari settings, set to the domain's notification settings to deny trigger push notification on server. it's response will still be 200 even though the subscription is now invalid
Replies
1
Boosts
1
Views
1.3k
Activity
Nov ’22
Web Push and Push notifications
Apple recently introduced and presented Web Push, a new Web Kit tool permitting to send notifications to users on your websites and web apps. However, push notifications have been a thing on macOS since Mavericks. Therefore, what is the difference between these two things ?(https://developer.apple.com/notifications/safari-push-notifications/ ) and that new thing (https://developer.apple.com/videos/play/wwdc2022/10098/)
Replies
2
Boosts
1
Views
2.5k
Activity
Aug ’22