web-push-libs / web-push-csharp

Web Push library for C#
Mozilla Public License 2.0
429 stars 108 forks source link

Apple web push causing errors #97

Open briwg opened 1 year ago

briwg commented 1 year ago

Hi,

I'm starting to see registrations for Apple web push and they are causing errors such as:

Exception thrown: 'System.AggregateException' in mscorlib.dll An exception of type 'System.AggregateException' occurred in mscorlib.dll but was not handled in user code One or more errors occurred.

I'm using the latest version of the dll.

Thanks

Brian

keke1210 commented 1 year ago

@briwg based on the readme file, the Safari browser is not supported. image Meanwhile, on the node.js package(https://github.com/web-push-libs/web-push), the safari browser is supported

briwg commented 1 year ago

Yes, I understand that. However, the point is that people can land on my website using IOS Safari and subscribe to Push Notifications. When I then send out a PN an uncaught exception is thrown by the dll when the apple endpoint is encountered and my sender errors and stops. I have put a workaround in place, but the dll in my view should either a) handle the exception internally b) be updated to support Apple IOS push notifications since it appears they are now finally being rolled out.

keke1210 commented 1 year ago

@briwg I am rooting for option b.

7702244 commented 1 year ago

Safari for MacOS have full support for standard PUSH API which works perfectly with this library. According to presentation, support for iOS and iPadOS will appear next year.

But unfortunately, the library looks abandoned and is no longer being developed.

WebPush for Safari

Stratster commented 1 year ago

So i believe i have found the issue here...

After searching through the differences from the main js project and this one, i noticed that this library does not support the content encoding AES_128_GCM which is required by safari as you can see in the Authorization header description here: Send push notifications to Safari users

This feature is requested since 2018...: 44

DaBeSoft commented 1 year ago

I ran into a similar (but maybe not the same) problem where I got "403 - BadJwtToken" as an error.

The solution to my problem was to remove the "<" and ">" from the mailto in the VAPID subject (from mailto:<mail@example.com> to mailto:mail@example.com). It seems that Apple does not like them. (see https://stackoverflow.com/questions/75547851/sending-push-notifications-to-safari-from-java)

Push notifications now work fine for me (Safari on iOS) using this library. Hope this helps.

briwg commented 1 year ago

DaBeSoft do you know if this works with iOS and iPadOS 16.4 devices which support web push?

See: https://webkit.org/blog/13878/web-push-for-web-apps-on-ios-and-ipados/

DaBeSoft commented 1 year ago

Yes, it does work, but afaik the web app needs to be added to the homescreen for Push Notifications to work on iOS / iPadOS (as described in your link).