Android : standalone Push notifications not displaying "heads up" when app is closed / background

I have an undetached Expo Android application and am currently blocked on being able to display push notifications when the app is backgrounded or inactive.

This is only an issue with standalone Android. On standalone iOS push notifications display as expected even when the app is not running. When deployed in the Expo container there were no such issues on Android.

When the app is running in the foreground the message is intercepted and handled via the Expo.Notifications.addListener handler and is not a problem. However when the app is running notifications are less important for us as the user is engaged.

The message is received by the device correctly and indeed it will display in the Notification Panel tray at the top of the mobile device’s screen, however this occurs silently with no sound or vibration. A red dot will also appear on the top right of the app’s icon with a message number incremented, however again, this would only be visible to a user currently viewing that page of their installed apps.

Plenty of other apps on this Android device are able to display “heads up” notifications when the app is not running or backgrounded. But I as yet have not managed to find the configuration to allow this behaviour on standalone Expo Android apps.

Device = Xiaomi Redmi 5 running Android 7.1, but I have tested several devices on Android 7 / 8.
Expo Version = 32.0.0
Messages sent via the Expo Push notification tool or via the server with the syntax listed below. Both exhibit the same behaviour.

From the server the message format is as follows:

{
    to: pushToken,   // ExponentPushToken[........]
    sound: 'default',
    title,
    body,
    channelId: 'my-channel',  // android 8.0 later
    priority: 'high',
    content_available: true,
    data: {
      title,
      body,
    },
    'show_in_foreground': true,
  };

How can I configure the app such that push notifications are displayed popped up when the app is running in the background or is closed?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.