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

In android events are not getting triggered in.

Open chaitanya71998 opened this issue 2 years ago • 4 comments

Hi

I was integrating react-native-notifications package to react native app. With ios it is working absolutely superb. But for android this not working completely. apart from registerRemoteNotificationsRegistered remaining events are not at all getting triggered.

//index.tsx
import {Notifications} from 'react-native-notifications'
...
  useEffect(() => {
    Notifications.registerRemoteNotifications()
    Notifications.events().registerRemoteNotificationsRegistered(
      (event: Registered) => {
        console.log('registerRemoteNotificationsRegistered', event)
      },
    )
    Notifications.events().registerNotificationReceivedForeground(
      (
        notification: Notification,
        completion: (response: NotificationCompletion) => void,
      ) => {
        console.log('registerNotificationReceivedForeground', notification)//not getting triggered
        // Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
        completion({ alert: '1', sound: '1', badge: '0' })
      },
    )

    Notifications.getInitialNotification()
      .then(notification => {
       console.log(notification) // getting undefined, everytime
      })
      .catch(err => {
      })

    Notifications.events().registerNotificationOpened(
      (
        notification: Notification,
        completion: () => void,
        action: NotificationActionResponse,
      ) => {
        console.log(notification) //not getting triggered
        completion()
      },
    )

    Notifications.events().registerNotificationReceivedBackground(
      (
        notification: Notification,
        completion: (response: NotificationCompletion) => void,
      ) => {
        console.log('registerNotificationReceivedBackground', notification) ////not getting triggered
        completion({ alert: true, sound: true, badge: false })
      },
    )

    webengage.push.onClick(function (notificationData: { [x: string]: any }) {
console.log(notificationData) // working fine
    })
  }, [])

I have followed the steps in the installation docs as it : https://wix.github.io/react-native-notifications/docs/installation-android version: "react-native-notifications": "^4.3.5",

chaitanya71998 avatar Jul 18 '23 13:07 chaitanya71998

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'm also having this issue. I don't know if some code somewhere is causing issues with the library, but aside from the events having been triggered a few times in the past, I can't get them to trigger again, I guess we are the minority? We have probably done something to interfere with the library 🤔

disrae avatar Sep 21 '23 23:09 disrae

I'm experiencing something similar with version 5.1.0 when I'm trying to handle the notifications in the foreground for Android. For iOS seems fine and the event is triggered

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

I don't know if this problem exists for you or not, but I added android.permission.SYSTEM_ALERT_WINDOW and it's gone.

Barney4242 avatar Mar 21 '24 19:03 Barney4242

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 Jan 31 '25 22:01 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Feb 24 '25 23:02 stale[bot]