Open laijackylai opened 1 year ago
Using FirebaseAdmin
After adding channelid in server code, push message popup in foreground.
Before
var message = new Message()
{
Token = deviceToken,
Notification = new Notification
{
Body = body,
},
};
After
var message = new Message()
{
Token = deviceToken,
Android = new AndroidConfig
{
Notification = new AndroidNotification
{
ChannelId = "my-channel",
Body = body,
},
},
};
In react native APP, pass "notification.payload" back to postLocalNotification function. It is "notification.payload". Not "notification".
Notifications.events().registerNotificationReceivedForeground((notification, completion) => {
if (Platform.OS == 'android') {
Notifications.postLocalNotification(notification.payload);
}
completion({alert: true, sound: true, badge: false});
});
The channel ID is set by setNotificationChannel
Notifications.setNotificationChannel({
channelId: 'my-channel',
name: 'My Channel',
importance: 5,
description: 'My Description',
enableLights: true,
enableVibration: true,
groupId: 'my-group', // optional
groupName: 'My Group', // optional, will be presented in Android OS notification permission
showBadge: true,
});
open issue: https://github.com/wix/react-native-notifications/issues/891