8

I am using the following code to create two channels for my expo react app, on Android:

Notifications.setNotificationChannelAsync("default", {
            name: "default",
            importance: Notifications.AndroidImportance.MAX,
            vibrationPattern: [0, 250, 250, 250],
            lightColor: "#FF231F7C",
        })  

Notifications.setNotificationChannelAsync("gameupdates", {
                name: "gameupdates",
                importance: Notifications.AndroidImportance.MAX,
                vibrationPattern: [0, 250, 250, 250],
                lightColor: "#FF231F7C",
            })

The channel is successfully created and I can even find it when I go into the Expo app notification options.

When I send a notification using expo's tool without any channel id, it works fine. However, when I use the channel id "gameupdates", the notification never reaches my phone.

Any idea why?

I am on the expo sdk 38.

Ryan Pergent
  • 4,432
  • 3
  • 36
  • 78

3 Answers3

3

Fixed it! The issues was that I needed to add android.useNextNotificationsApi: true to the app.json. Then I had to do expo:build and manually upload the build.

Ryan Pergent
  • 4,432
  • 3
  • 36
  • 78
1

You have created your channel successfully but doesn't updated your app's expo notifications settings. For this you must add -

android: {
...
"useNextNotificationsApi": true
}

in your app.json file.

Then just run your code by clearing expo cache like -

expo start -c

And test it! You will start receiving the notifications on your Android 10+ mobiles also.

AMOL PATIL
  • 91
  • 1
  • 3
0

Follow the documentation:

If you create a notification and do not specify a channelId, Expo will automatically create a 'Default' channel for you and present the notification through that channel. If, however, you specify a channelId that has not yet been created on the device, the notification will not be shown on Android 8+ devices. Therefore, it's important to plan ahead and make sure that you create all of the channels you may need before sending out notifications.

On devices with Android 7 and below, which don't support notification channels, Expo will remember the relevant settings you created the channel with (in this case, sound: true) and apply them directly to the individual notification before presenting it to the user.

So I think must be make sure somethings if you want to push to specify channel id:

  • Your app run on devices 8.0+
  • Channel create success on device without effect any setting from user (in case check you gameupdates channel)
  • Take care your android app run on API 26+

Good luck.

dinhlam
  • 708
  • 3
  • 14
  • The device is on android 10, the channel is successfully created (as I said, I can even find it as active in the notification settings on the expo app) and I am using the latest version of the expo app to test it. :( – Ryan Pergent Aug 14 '20 at 22:11
  • _createNotificationAsync = () => { Notifications.presentLocalNotificationAsync({ title: 'Reminder', body: 'This is an important reminder!!!!', android: { channelId: 'reminders', color: '#FF0000', }, }); } – dinhlam Aug 15 '20 at 02:38
  • Did you create a notification with `gameupdates` channel? – dinhlam Aug 15 '20 at 02:39
  • Yes, my problem is that when I send a notification with the `gameupdates` channel id it never reaches the phone. Also, I am not using local notifications but sending from the expo tool. – Ryan Pergent Aug 15 '20 at 12:15