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.7k stars 280 forks source link

Notifications in PWABuilder app using own server (without third-party services like One Signal, Firebase) #4477

Closed sans1994 closed 10 months ago

sans1994 commented 11 months ago

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

Can my app can receive notifications using PWABuilder considering these conditions?

Is it possible that additional settings are needed like 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?

khmyznikov commented 11 months ago

You can take a look here https://github.com/khmyznikov/ios-pwa-wrap how the notifications made for apple store pwa. You need to rely on ios native push. Web Push will not work in this case.

sans1994 commented 10 months ago

@khmyznikov Thank you for the feedback! Could you please also guide me if I understand the further steps for transitioning to ios-pwa-wrap correctly?

  1. I am currently completely abandoning PWABuilder.
  2. I'm integrating the pwa-shell from the ios-pwa-wrap repository.
  3. Configuring it with Xcode for my pwa. It would be great if you could provide documentation on what specific project settings in Xcode should be changed for the pwa-shell to work fully and be releasable. At the moment, I think I'll figure it out by comparing it to how PWABuilder configures and i will set the same parameters. This would be very helpful for people, who are not familiar with Xcode but need to convert a pwa into an iOS app using your pwa-shell.
  4. I'm adding the logic described in the documentation to the service-worker - Push permission request, Push permission state, Push notifications handle, alongside the web-push logic (in parallel, as I need to keep web-push for pwa and android app).
  5. I'm following the documentation for setting up Firebase.
  6. In the backend part where web-push notifications are sent, I'm also adding logic to send notifications to Firebase (which will redirect the notifications to the app).

I have come up with this implementation path for myself. It seems logical to me, but i wanted to make sure I've thought everything correctly.

khmyznikov commented 10 months ago

@sans1994 1 ios-pwa-shell is == PWABuilder ios template but with Push Notifications code uncommented. You don't need to change the source code, just compare which part you have commented in your current project. 4 You will need to have Web Push API logic with SW for: Safari, Android, Windows. And Apple Push logic + custom events provided on a web side JUST for Apple Store. 6 You can use Firebase framework for both iOS and Web push. (general advice: don't use firebase provided service worker)

sabres207 commented 7 months ago

4 You will need to have Web Push API logic with SW for: Safari, Android, Windows. And Apple Push logic + custom events provided on a web side JUST for Apple Store.

I saw in other thread you said it's possible to switch to OneSignal. Do you know how it's done? More specifically, in OneSignal, they ask to choose a target SDK (either NativeIOS / Cordova etc. / Other SDK), and when choosing Other sdk, they ask to configure OneSignal in the app sdk.

Abrissirba commented 7 months ago

@khmyznikov Do you have any sources on why you need to implement native push on IOS? I trying to understand why this is not supported. It would be really nice to only have to implement web push.