@jordangio wrote:
I have some questions and I hope you can shed some light on all of those. Right now, I have a PWA written. No cordova or anything. Pure PWA with service worker, workbox and offline support.
Requirements:
a) I need to have a PWA website so that users can see my website via url.
b) I need my app to be on play store and app store.
c) I need the website and my apps to support push notifications.Question 1) As you know, It’s possible to publish PWA on google play store and somehow app store(not sure yet). But if I do that, I won’t be able to have push notifications for IOS. so the only way if I want to provide push notifications for ios too is to use
cordova
orcapacitor
. Am I right?Quesiton 2) If I use
capacitor
, then publishing PWA to playstore and appstore isn’t worth it because by usingcapacitor
i already can publish them as almostnative
apps. Is that right? is this how you would do it?Question 3) I tried to use
capacitor
for the first time today and here is the code I’ve written for push notifications.import { Plugins } from '@capacitor/core' const { PushNotifications } = Plugins; PushNotifications.register(); PushNotifications.addListener('registration', function(e){ console.log("eee ", e); }) PushNotifications.addListener('registrationError', function(e){ console.log("err ", e); });
the thing is, when building this through
xcode
after I usenpx add ios
andnpx cap copy
, I can see thatpush
notifications work on ios now. The bad thing is that now, If I run this via my website url, let’s say chrome, it says thatUncaught (in promise) PushNotifications does not have web implementation.
. So Now, I’m really stuck. Does this mean that I have useif else
statements to first check what targetuser uses
and if it’sweb
, I should usebrowser's PushAPI
? and if the target isios or android
, I’d use the above code. Because of the fact that I useservice worker
because my app is PWA, I can simply putpush
listener in service worker and now, I’d make push notifications for all platforms. Is thisif else
and checking platform and usingPushAPI
orcapacitor's push notifications
a great practice? or what other idea can you provide?Question 4) It turns out that if I use
capacitor
i have to include@capacitor/core
which will make the bundle size bigger for web. Now, the thing is if user goes to web version, My website size will be bigger, but the thing is size is bigger, but i don’t usecapacitor's plugin
at all. Is this unavoidable?I’d really appreciate your sincere answers since there’s not many people who can help.
Posts: 1
Participants: 1