pwa-builder / PWABuilder

The simplest way to create progressive web apps across platforms and devices. Start here. This repo is home to several projects in the PWABuilder family of tools.
https://docs.pwabuilder.com
Other
2.75k stars 284 forks source link

[iOS] Support Push Notifications via Firebase or other service #2434

Open JudahGabriel opened 3 years ago

JudahGabriel commented 3 years ago

The iOS project we're using supports Push Notifications via Firebase. Currently, the code is commented out, and PWABuilder doesn't give any UI for it.

We could uncomment the push notification code and add UI in PWABuilder to allow you to specify your Firebase push notification details.

If Push Notifications are important to you, please ๐Ÿ‘ this issue.

kriti-jain-unbiased-co-uk commented 1 year ago

Any workaround by which I can integrate One Signal messaging service to send some push notifications to the PWA builder generated iOS app?

sivertheisholt commented 1 year ago

What is the chance of this working when 2024 arrives? I have a project that would like PWA app to be available in app store and support push notifications.

khmyznikov commented 1 year ago

@raghulkrishna @kriti-jain-unbiased-co-uk @sivertheisholt nothing changed. Web Push API available only for installed Chrome/Safari PWA. Not a Apple Store distributed. Workaround is the same: https://github.com/khmyznikov/ios-pwa-wrap you can potentially swap Firebase to One Signal.

joelwillis commented 1 year ago

Just published my PWA app to the app store. Everything is great other than the push notification issue. (Push notifications work with the PWA added to home screen from Safari, but not on the app store version.) Any line of sight for this to be resolved? I'd rather not implement a workaround, but the lack of push notifications is a showstopper.

mlstubblefield commented 1 year ago

Any updates on this?

sans1994 commented 1 year ago

@khmyznikov @SuperPat45 @tntjstumadre I have an iOS app built using PWABuilder. And I have my server that works with notifications (not third-party services like One Signal or Firebase).

Do you know if my app can receive notifications using PWABuilder considering these conditions?

Is it possible that additional settings are needed for certificates or in Xัode?

Everything works great for now, but only if the app is installed from the browser and not from the app store.

There is also a problem with the application not displaying a popup request to confirm the possibility of sending notifications to the user (only in-app, in pwa installed from the browser everything is OK). Is this problem also due to PWABuilder or is there still something I need to configure?

c-schicho commented 9 months ago

since there has already past quite some time since the last comments. are there any updates on this? is there now a better solution than the workaround proposed above?

jarofbilly commented 9 months ago

@sans1994 WebPush works when using the "add to home screen" from Safari but is currently unsupported by Apple in WKWebView which is what PWABuilder uses. Only alternative I have found is to use firebase.

nbignu commented 9 months ago

I am using firebase with the code that PWABuilder includes. But the fcm token is never printed in console. I am getting the following warning

@uiapplicationmain [security] this method should not be called on the main thread as it may lead to ui unresponsiveness.

I cannot tell if the token is not printing in console due to this warning, but the app is running well all in all. The only issue is that the token is not printing, although the firebase seems to be set up OK. As it shows the notification banner when I drag the following file with .apns extension to the simulator:

{ "Simulator Target Bundle": "BUNDLE ID", "aps": { "alert" : { "title" : "Hi there", "body" : "Test!" }, "sound": "default", "badge": 1 } }

Did anybody encounter this issue or can shed some light on this? I am looking forward to printing the fcm token and then use the local storage method with evaluatejs to send it to the backend on the client side and not with swift.

khmyznikov commented 9 months ago

https://github.com/khmyznikov/ios-pwa-wrap/issues/2#issuecomment-1547624335

sabres207 commented 9 months ago

After reading this thread I'm still a bit confused. Is it possible to send push notification to pwabuilder apps installed via app store? And if so, what are my options? firebase, oneSignal, in house implementation?

sabres207 commented 9 months ago

Just published my PWA app to the app store. Everything is great other than the push notification issue. (Push notifications work with the PWA added to home screen from Safari, but not on the app store version.) Any line of sight for this to be resolved? I'd rather not implement a workaround, but the lack of push notifications is a showstopper.

did you find a workaround / any solution for that?

johnfilo-kmart commented 9 months ago

I had success using this pwa wrapper instead of pwabuilder and using Firebase, using the javascript documented under JS Features in the README of that repo https://github.com/khmyznikov/ios-pwa-wrap

JohnHHunter commented 6 months ago

Looking for an update on this issue.

The docs have a section on Push Notifications. Is this issue still open? Are people able to send Push notifications to a wrapped PWA on iOS devices?

c-schicho commented 6 months ago

I recently implemented push notifications in ios apps built with pwa builder. For one project I used firebase and pushy for the other one. it's possible to send push notifications via apns to ios devices. nonetheless, you'll need to adapt the swift code based on what service you are going to use. definitely check out the comments in AppDelegate.swift.

you can then use events to transfer the information you need between the ios app and the web application. for this, you can check out this repo https://github.com/khmyznikov/ios-pwa-wrap as an example . you can find all available events (or add new) in WebView.swift. In ViewController.swift is the handler of these events and the actual implementations of the individual functions are mainly in PushNotifications.swift.

bnijenhuis commented 6 months ago

I recently implemented push notifications in ios apps built with pwa builder. For one project I used firebase and pushy for the other one. it's possible to send push notifications via apns to ios devices. nonetheless, you'll need to adapt the swift code based on what service you are going to use. definitely check out the comments in AppDelegate.swift.

you can then use events to transfer the information you need between the ios app and the web application. for this, you can check out this repo https://github.com/khmyznikov/ios-pwa-wrap as an example . you can find all available events (or add new) in WebView.swift. In ViewController.swift is the handler of these events and the actual implementations of the individual functions are mainly in PushNotifications.swift.

@c-schicho Do you have any documentation on how you managed to do this? It sounds like the best solution for now, because there's not much activity on this issue. I'm not familiar with editing .swift-files, so if you could document what files should be changed and what the code should be, that would be VERY helpful.

micheal-ojemoron-thurgood commented 4 months ago

@c-schicho can you help with an example code, I am stuck with errors on Firebase, unsupported device. I got the webkit implementation working

TheoMaraval commented 2 months ago

Are there any updates and are some people able to send Push notifications to a wrapped PWA (e.g. wrapped with PWA builder) on iOS devices?

maiconcarraro commented 2 months ago

@TheoMaraval I got my app working, I followed these steps https://docs.pwabuilder.com/#/builder/app-store?id=push-notifications the only thing that I had to modify was the For code on JS side, take a look at this example component step to make it work w/ React. Everything else I followed strictly.

TheoMaraval commented 2 months ago

@TheoMaraval I got my app working, I followed these steps https://docs.pwabuilder.com/#/builder/app-store?id=push-notifications the only thing that I had to modify was the For code on JS side, take a look at this example component step to make it work w/ React. Everything else I followed strictly.

@maiconcarraro Hi, thanks for your answer ๐Ÿ™, but can you please send your example component? I canโ€™t access it in your answer!

maiconcarraro commented 2 months ago

@TheoMaraval I got my app working, I followed these steps https://docs.pwabuilder.com/#/builder/app-store?id=push-notifications the only thing that I had to modify was the For code on JS side, take a look at this example component step to make it work w/ React. Everything else I followed strictly.

@maiconcarraro Hi, thanks for your answer ๐Ÿ™, but can you please send your example component? I canโ€™t access it in your answer!

the one from the example is https://github.com/khmyznikov/ios-pwa-shell/blob/main/src/components/push.ts or do you need the react one? the messagehandlers are exactly the same, only difference is using w/ useEffect+useCallback

TheoMaraval commented 2 months ago

@TheoMaraval I got my app working, I followed these steps https://docs.pwabuilder.com/#/builder/app-store?id=push-notifications the only thing that I had to modify was the For code on JS side, take a look at this example component step to make it work w/ React. Everything else I followed strictly.

@maiconcarraro Hi, thanks for your answer ๐Ÿ™, but can you please send your example component? I canโ€™t access it in your answer!

the one from the example is https://github.com/khmyznikov/ios-pwa-shell/blob/main/src/components/push.ts or do you need the react one? the messagehandlers are exactly the same, only difference is using w/ useEffect+useCallback

If you have the react one it would be perfect, thanks a lot for your help ๐Ÿ™

maiconcarraro commented 2 months ago

@TheoMaraval I created a gist with the 2 components that I have, it handles both web push (that covers android shell) and a second component dedicated for iOS shell https://gist.github.com/maiconcarraro/0845af1acc7490fb57e4c119815f50fc

FiFolker commented 2 weeks ago

Hello, I am developing a PWA and I plan to turn it into an application for the stores. I'd like to know if the pwaBuilder project is still active and if this functionality will ever be available. Thank you and have a nice day.

maiconcarraro commented 2 weeks ago

@FiFolker you can follow https://docs.pwabuilder.com/#/builder/app-store?id=push-notifications the iOS package is still experimental, so probably that's why this issue is still open, I did the implemention for my app following the docs and everything worked fine ๐Ÿ‘

FiFolker commented 2 weeks ago

@maiconcarraro Ok thanks, this part of the doc isn't updated 'cause it says than we can't do push notifications on PWA https://docs.pwabuilder.com/#/builder/faq?id=can-i-use-push-notifications I also saw somes peoples saying than IOS was rejecting pwa on apple store even with builder that is true or not ?

maiconcarraro commented 2 weeks ago

@FiFolker got it, apps are being approved, you can even see some community showcases in discord, the app will be rejected if they aren't following Apple's requirements, for example if you only have google sign in, they will require you to also implement apple sign in. you need to be clear on cookies policy as well, just usual app review process.

@khmyznikov is it okay to send a PR changing the FAQ?