Android heads-up push notification Issue

I am using React Native with Expo and the @ua/react-native-airship library. Currently, I am receiving notifications in both the foreground and background on Android. However, the notifications only appear in the notification tray and not as heads-up notifications (the kind that briefly pop up on the screen).

On iOS, I was able to display heads-up notifications by using the following code:

if (Platform.OS === 'ios' && Airship.push.iOS) {
  console.log('Setting iOS foreground presentation options');
  await Airship.push.iOS.setForegroundPresentationOptions([
    iOS.ForegroundPresentationOption.Banner,
    iOS.ForegroundPresentationOption.Sound,
    iOS.ForegroundPresentationOption.Badge,
  ]);
}

This worked well to show the notifications as heads-up banners on iOS.

For Android, I have added the following XML file (ua_custom_notification_channels.xml) in the android/app/src/main/res/xml/ directory:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <NotificationChannel
        id="com.twocents.app"
        name="Twocents"
        description="Twocents notification channel"
        importance="3" />
</resources>

Despite setting the importance to 3 (which maps to IMPORTANCE_DEFAULT), the notifications are still not appearing as heads-up on Android. Is there anything else I need to configure in order to enable heads-up notifications on Android?

Didn't find what you were looking for?

New post

Comments

0 comments

Please sign in to leave a comment.