react-native-notifications icon indicating copy to clipboard operation
react-native-notifications copied to clipboard

completion() doesn't work on Android 12 (API 31)

Open mutablestudio opened this issue 2 years ago • 4 comments

I have followed all the Android setup instructions and have FCM setup, google-services.json, etc. registerNotificationReceivedForeground and registerNotificationReceivedBackground events both fire on Android but the completion() call does not show the Notification on Android (works fine on iOS).

"react-native-notifications": "5.0.0" - also tried 4.3.3, 4.3.1... "react-native": "0.68.5",

Samsung Galaxy S10e (api 31) and Pixel 3 devices.

I have to do the following to get a Notification to appear on Android:

   Notifications.events().registerNotificationReceivedForeground((notification: Notification, completion: (response: NotificationCompletion) => void) => {
      if (Platform.OS === 'android') {
        Notifications.postLocalNotification({
          title: "Notification",
          body: "You have a notification!",
          extra: "data"
        })
      } else {
        // Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
        completion({alert: true, sound: true, badge: true});
      }
    });

Am I missing something for the Android setup??

mutablestudio avatar Aug 03 '23 08:08 mutablestudio

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Sep 16 '23 23:09 stale[bot]

I have the same issue. I am not an android developer so I do not understand the ecosystem that well. It feels like I have everything setup correctly as I can send push notifications from AWS and my app does receive the message both when the app is running in the foreground as well as background. (via console.log in the event handlers.) Nothing happens when the app is 'dead'.

In IOS the notification seems to be handled by the operating system and displayed without the app being open or in the background. Does the android app need to do something to display the notification? If the app is dead how is that code going to run?

Any help appreciated.

mattsoftware avatar Oct 10 '23 23:10 mattsoftware

I'm experiencing something similar with version 5.1.0 when I'm trying to handle the notifications in the foreground.

luca-tomasetti avatar Nov 29 '23 13:11 luca-tomasetti

Similar problem

VladislavAnanyev avatar Feb 04 '24 19:02 VladislavAnanyev

In the docs completion seems to be an ios only feature. Am i wrong? The docs is not clear

"Should call completion function on iOS, will be ignored on Android."

https://wix.github.io/react-native-notifications/api/general-events

levepic avatar Jan 26 '25 09:01 levepic

In the docs completion seems to be an ios only feature. Am i wrong? The docs is not clear

"Should call completion function on iOS, will be ignored on Android."

https://wix.github.io/react-native-notifications/api/general-events

To solve the issue, I decided to migrate my code to this repo: https://github.com/invertase/notifee

luca-tomasetti avatar Jan 27 '25 08:01 luca-tomasetti

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Mar 07 '25 22:03 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Apr 25 '25 00:04 stale[bot]