invertase / react-native-notifee

Moved to https://github.com/invertase/notifee
https://invertase.io/blog/open-sourcing-notifee
Other
466 stars 31 forks source link

[Android] Question: is it possible to use the system alert UI to show the notification #353

Closed RayVR closed 3 years ago

RayVR commented 3 years ago

I'm somewhat confused as to why the behavior of notifee on Android differs so much from iOS and react-native-push-notification (I am not experienced with the Android platform)

Notifications on Android are essentially hidden from the user until they pull down the system tray. Is there a recommended way to show a notification slide in from top similar to iOS or react-native-push-notification?

helenaford commented 3 years ago

Hey there, thanks for the question - I think this does trip people up, including myself. It's an Android requirement that if you need the notification as a heads-up notification, the channel needs to have the importance of high (ref: https://notifee.app/react-native/reference/androidimportance#high):

import notifee, { AndroidImportance } from '@notifee/react-native';

const channelId = await notifee.createChannel({
  id: 'important',
  name: 'Important Notifications',
  importance: AndroidImportance.HIGH,
});

await notifee.displayNotification({
  title: 'Your account requires attention',
  body: 'You are overdue payment on one or more of your accounts!',
  android: {
    channelId,
    importance: AndroidImportance.HIGH,
  },
}); 

It's easier on iOS as this is the default behavior.

Hope that helps

RayVR commented 3 years ago

This is a huge help.

Thank you!

On Aug 5, 2021, at 20:18, Helena Ford @.***> wrote:

 Hey there, thanks for the question - I think this does trip people up, including myself. It's an Android requirement that if you need the notification as a heads-up notification, the channel needs to have the importance of high (https://notifee.app/react-native/reference/androidimportance#high):

import notifee, { AndroidImportance } from @.***/react-native';

const channelId = await notifee.createChannel({ id: 'important', name: 'Important Notifications', importance: AndroidImportance.HIGH, });

await notifee.displayNotification({ title: 'Your account requires attention', body: 'You are overdue payment on one or more of your accounts!', android: { channelId, importance: AndroidImportance.HIGH, }, }); It's easier on iOS as this is the default behavior.

Hope that helps

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.