Post

Replies

Boosts

Views

Activity

Generating and receiving token for Push Notifications stopped working
Hi, hope you're all doing well. I have a real brain-cracker here... Have been looking into this for the past 20 hours, but can't figure it out. We built an iPhone app that essentially functions as a shell around a PWA Web-App using WebView. The tricky part here to set things up was getting the Push Notifications to work. Eventually we got this working though (with help of Firebase), and the app has been working great for the past 7 months. Now, all of a sudden as it seems, when users first open up the app, there's no FCM token generated and passed on to the WebView instance running javascript. Or at least, the listening event ('push-token') no longer gets fired. Users who already have their FCM token generated and stored earlier on, receive push notifications without any issues. It's just that no new FCM tokens seem to be generated - or at least no longer passed to the WebView's javascript code. I know this for a fact as my tests turn out that the following event (present in my PWA Web-App JS code) no longer gets fired. Again, this worked fine before. I have NOT updated the native app since 6-7 months. `/* LISTEN FOR FCM (PUSH MESSAGES) TOKEN FROM NATIVE (IOS) SHELL: */ window.addEventListener('push-token', function(event) { //alert("Push Token registration event called from native shell"); if (event && event.detail) { var token = event.detail; window.fcmPushMessageToken = token; localStorage.setItem('fcmPushMessageToken', token); //alert("Received FCM token: " + token); registerDeviceForPushMessages(); } });` Hereé the part in my native iOS code that used to call this event from within the native iOS shell: func handleFCMToken(){ DispatchQueue.main.async(execute: { Messaging.messaging().token { token, error in if let error = error { print("Error fetching FCM registration token: \(error)") checkViewAndEvaluate(event: "push-token", detail: "ERROR GET TOKEN") } else if let token = token { print("FCM registration token: \(token)") checkViewAndEvaluate(event: "push-token", detail: "'\(token)'") } } }) } func checkViewAndEvaluate(event: String, detail: String) { if (!EPDriversApp2.WebView.isHidden && !EPDriversApp2.WebView.isLoading ) { DispatchQueue.main.async(execute: { EPDriversApp2.WebView.evaluateJavaScript("this.dispatchEvent(new CustomEvent('\(event)', { detail: \(detail) }))") }) } else { DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { checkViewAndEvaluate(event: event, detail: detail) } } } Again, I have not updated the native iOS app OR the WebApp's code. This just stopped functioning all of a sudden. One "weird" thing I noticed that there's no Provisiong Profile associated with the app. I'm not sure whether this was ever the case before, to be honest. Is this even mandatory? Can not having a Provisiong Profile associated with the app effect the ability of an already pusblished app for generating Push Notification tokens?
0
0
202
Oct ’24