web-push-libs / webpush-java

Web Push library for Java
MIT License
318 stars 112 forks source link

How to add an icon or an image to the web push notification #148

Closed kopax closed 4 years ago

kopax commented 4 years ago

Hello, I am reading Notification class and I can't see where the icon or image can be set, could you please show us an example? Thanks in advance

Source: https://developer.mozilla.org/en-US/docs/Web/API/Notification/icon

martijndwars commented 4 years ago

This library is used on the server to send the push message. Upon creating the push subscription, the browser registers a service worker that can listen to push events. It is up to the service worker to create the notification. As such, creating the notification is outside the scope of this library.

kopax commented 4 years ago

Yes I figured out all that my self that is why I have closed the issue. Thank you for the reply still. I have implemented my self the same mechanism but for web push token, I got them working in my expo app, do you have an idea why expo does not allow them at that time? Will you add the support later if a day they would support it?

martijndwars commented 4 years ago

I got them working in my expo app, do you have an idea why expo does not allow them at that time?

I assume you are referring to expo.io? I have no experience with Expo, so I cannot really answer this. Are you saying you got it working with Expo? Or does it not work because Expo does not allow push notifications?

iOS does not support the Web Push protocol, so if you are deploying your Expo app as an iOS app, then that likely won't work. You need to use Apple Push Notification Service (APNS) to support iOS. In fact, Expo has their own Push API that forwards push messages to either Web Push (Android) or APNS (iOS). Is that what you are looking for?