Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

[ANDROID] Foreground Service notification is dismissable #1248

@get-Friday

Description

@get-Friday

Hello team,

1. Summary

I'm trying to implement a simple foreground service notification and everytime I create a notification it creates as a dismissable notification.

2. Enviroment

expo: 53.0.19
react-native: 0.79.5
react: 19.0.0

3. Platform

This problem happened on:

  • Android Emulator API 35
  • Android Device Version 15

4. Steps to problem

  1. Install @notifee/react-native: npm install @notifee/react-native
  2. Generate development build: eas build --profile android --platform development
  3. Install development build on device and on emulator
    3.a. on Emulator, create prebuild to generate necessary files to run on emulator.
  4. Register the foreground service on my App.js file
import notifee from '@notifee/react-native';

notifee.registerForegroundService(notification => {
  return new Promise(() => {
    console.log('Foreground service:', notification);
  });
});
  1. Create a notification
const handleStartNotificationService = async () => {
    const channelId = await notifee.createChannel({
      id: 'foreground-service-notification',
      name: 'Test channel',
      importance: AndroidImportance.HIGH,
      visibility: AndroidVisibility.PUBLIC,
    });

    try {
      await notifee.displayNotification({
        title: 'Foreground service',
        body: 'This notification will exist for the lifetime of the service runner',
        android: {
          channelId,
          asForegroundService: true,
          color: '#0020FF',
          colorized: true,
          importance: AndroidImportance.HIGH,
          visibility: AndroidVisibility.PUBLIC,
        },
      });
    } catch (error) {
      console.error('Error starting notification service:', error);
    }
  };
  1. Call in on a button
<Button title={'PRESS ME'} onPress={handleStartNotificationService} />
  1. On pressing notification is created
    7.a. a console.log on notification inside my registerForegroundService shows the following:
{"android": {"asForegroundService": true, "autoCancel": true, "badgeIconType": 2, "channelId": "foreground-service-notification", "chronometerDirection": "up", "circularLargeIcon": false, "color": "#0020FF", "colorized": true, "defaults": [-1], "groupAlertBehavior": 0, "groupSummary": false, "importance": 4, "lightUpScreen": false, "localOnly": false, "loopSound": false, "ongoing": false, "onlyAlertOnce": false, "showChronometer": false, "showTimestamp": false, "smallIcon": "ic_launcher", "visibility": 1}, "body": "This notification will exist for the lifetime of the service runner", "data": {}, "title": "Foreground service"}
  1. On sliding notification horizontally it is succesfully dismissed
Image

4.a Expected behavior

On step 8. Notification stays fixed

5. Final considerations

I would love to use this library but I couldnt figure it out how to make this work as I intend it to.

Thanks in advance for anyone trying to help, I will work a few days more to try and find a solution. If I succeed I will post it here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions