Chicken vs. Egg: how to transition to Android notification channels without breaking anything


#1

Suppose I have an existing app that hasn’t yet been upgraded to use notification channels. I update my client code to create a notification channel and I upgrade my server-side push notification code to specify a channel ID. I push both of these updates to production / Play Store.

If I’m reading the documentation correctly for the push notification HTTP API, once I specify a channelId, anybody with a client version that does not register the notification channel will not get those push notifications. If I update my server on August 1st, but a client does not get the update from the Play Store until August 5th for whatever reason, they’re not going to get push notifications for that time period.

Conversely, if I don’t update my server but push my client update with the notification channel code, that weird “default” channel will get created and I won’t be able to clean it up.

Anyway, what’s the recommended way to do this? Seems like having the default channel for a while as users get the client update is the best of two non-ideal options (because at least users get the notifications), but maybe I’m missing something. Thanks!


#2

Hi @llamaluvr – thanks for the question, this is definitely a confusing upgrade.

once I specify a channelId, anybody with a client version that does not register the notification channel will not get those push notifications.

^This is actually not quite correct. The channel filtering happens client-side, so any existing clients that are built targeting Android 7 (meaning they were built before June) will simply ignore the channelId field and display notifications as normal.

The only time clients might miss notifications is in the short period of time between when they DO upgrade and when they run the upgraded app & the notification channel is created. I’d recommend creating the channel as early as possible in the app lifecycle in order to minimize this.

Also note that this will only affect users on Android 8 and above. Users on Android 7 and below should not experience any change in behavior.

Finally, it is possible to delete the “default” channel if you decide to go that route instead – the OS system settings will just display a small bar that says “1 deleted category” or something like that.

Hope that helps. Let me know if you have any other questions!


#3

Thanks! So, it sounds like, since my users are still on a pre-SDK 26 version, I can update my server-side code anytime before I put out a new version and they’ll still keep getting notifications.

I guess there is the potential, once they do upgrade the app, that I have some users where the OS upgrades the app and they don’t use it for a while, and they wouldn’t get notifications as a result. But at least I can present that risk to the stakeholders and see what they think (we don’t have that big of an Android audience yet).

Regarding deleting the default channel, is that something I can do with the Expo API, or would that only be possible with some native code in a detached app? In other words, is there a corresponding Expo.Notifications.deleteChannelAndroidAsync() ?

Thanks!


#4

Hi @llamaluvr - yes, that all sounds correct. And yes, there is exactly the method you described: https://docs.expo.io/versions/v28.0.0/sdk/notifications#exponotificationsdeletechannelandroidasyncid :slight_smile: We don’t export the id of the default channel but it’s just 'expo-default'.


closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.