I am engaged on a Flutter Net app that makes use of net push notifications. My setup works properly on most platforms, however I am experiencing points on iOS when the PWA is added to the house display screen.
This is the code I take advantage of for the push occasion listener in my service employee:
self.addEventListener('push', occasion => {
console.log("Acquired push occasion:", occasion);
if (occasion.knowledge) {
strive {
const knowledge = occasion.knowledge.json();
handlePushMessage(knowledge);
} catch (error) {
console.error("Error parsing push message knowledge:", error);
}
} else {
console.error("No knowledge in push occasion.");
}
});
Contained in the handlePushMessage perform, I course of the info, regulate the badge, and carry out some additional work. I then try and ship knowledge to index.html and my Flutter app courses utilizing channel.postMessage or purchasers.matchAll().
This method works on most platforms, however on iOS when the app is put in as a PWA on the house display screen, I encounter points. The information doesn’t get despatched to index.html, and it looks as if postMessage or purchasers is not functioning as anticipated.
Confirmed the service employee is registered and lively.
Used purchasers.matchAll() to get shopper cases to ship messages to, however with out success.
Examined completely different messaging approaches between the service employee and the primary app.
Query
Why may channel.postMessage or purchasers.matchAll() be unable to ship knowledge from the service employee to index.html in a Flutter Net PWA on iOS? Is there an iOS-specific limitation or workaround for this situation?
Any insights or solutions could be vastly appreciated!