An Interest In:
Web News this Week
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
- April 12, 2024
- April 11, 2024
Upgrading from Capacitor 2 in 2024 - Part 3: OneSignal
Another big plugin we needed to upgrade was the OneSignal notifications plugin. We were still at version 2 for this plugin, with 5 being the latest, so we knew we had some work to do here.
Unfortunately the official documentation only showed how to initialize and handle a simple notification and we could not find how to migrate the other features we use, like enabling or disabling notifications from the app.
We tried looking at other solutions, like the Capacitor push-notifications-plugin. It seemed to have everything we needed, but required a full rework of all the code in the app and some backend work too. This was too big of a change to do at that moment, so we had to do more research
Finding the treasure
But after some digging in the GitHub repository, we found the migration guide.
Following this guide, we could upgrade the plugin to the latest version, and the only problem we encountered was actually us not fully understanding how OneSignal works with fresh installs.
Fresh installs equals new subscription
We wanted to test sending a notification to a user, so we found our test device in the subscriptions with OneSignal,
and marked it as a test account. We could then send a test notification, and it showed up on the device.
So we continued implementing the enabling and disabling of the notifications from the app. When testing this with our marked test device, we saw no updates happening to the subscription! A lot of frustrations, verbose logging and installations later, we noticed that the UUID of the new install did not match the UUID of the test account!
So for every new installation, which happens with a rebuild, a new subscription id is used in OneSignal. So we just had to mark the new subscription id as a test account, and the notification arrived.
Original Link: https://dev.to/reconcept/upgrading-from-capacitor-2-in-2024-part-3-onesignal-536o
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To