SDK Version: 39.
Platform: Android.
I’m able to create a custom channel, ‘messages’, using “setNotificationChannelAsync”:
if (Platform.OS === 'android') {
Notifications.setNotificationChannelAsync('messages', {
name: 'Messages',
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: '#FF231F7C',
});
}
But then how do I use that custom channel?
The documentation gives the following simple example for using “scheduleNotificationAsync”:
async function schedulePushNotification() {
await Notifications.scheduleNotificationAsync({
content: {
title: "You've got mail! 📬",
body: 'Here is the notification body',
data: { data: 'goes here' },
},
trigger: { seconds: 2 },
});
}
According to the documentation, the only argument that “scheduleNotificationAsync” takes is “NotificationRequestInput,” which in turn can include “NotificationContentInput”. However, I did not see any mention of channelId.
I do see that some of the documentation for the now-depreciated “presentNotificationAsync” etc. makes mention of channelId:
android ( optional ) ( object ) – notification configuration specific to Android.
- channelId ( optional, but recommended ) ( string ) – ID of the channel to post this notification to in Android 8.0+. If null, defaults to the “Default” channel which Expo will automatically create for you. If you don’t want Expo to create a default channel, make sure to always specify this field for all notifications.
But what is the current way to use a custom channel with a local notification?