React-native-push-notification: Could not invoke RNPushNotification.getDeliveredNotifications

Created on 19 Feb 2021  路  11Comments  路  Source: zo0r/react-native-push-notification

Hello guys. We use remote push notifications. After use tapped on notification, we need to remove it. Everything works fine on real device when I build release and install it on device but when I upload my build to Google Play Console, after review it shows this:
Crash java.lang.RuntimeException: Could not invoke RNPushNotification.getDeliveredNotifications

https://clip2net.com/clip/m354799/71e28-clip-167kb.png?nocache=1

@zo0r do you know what can cause this issue?

Most helpful comment

All 11 comments

import PushNotification from "react-native-push-notification"
componentDidMount(){
  PushNotification.getDeliveredNotifications((data) => {
      data.map((notify, key) => {
          if(Platform.OS == 'android'){
              PushNotification.removeAllDeliveredNotifications({id: notify.tag});
          }
      })
  })    
}

How can I fix this or get rid of it?

Hi! Have the same problem.
Any updates?

I just removed this code and its fine but we dont remove push notifications now hahaha
Can you guys help us please?
@Dallas62 @zo0r

Feel like this library not supported anymore gg

Hi @darknessproduction
Can you share the full StackTrace? I'm not going to tape the whole error from a picture.
Regards,

You're awesome.
@Dallas62 @zo0r
Look at this full logcat
https://sarzhevsky.com/rnpn.txt

And this is what triggered the error that you've seen in the screenshot
FATAL EXCEPTION: mqt_native_modules Process: com.swattage.tribe, PID: 28197 java.lang.RuntimeException: Could not invoke RNPushNotification.getDeliveredNotifications at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:383) at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151) at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loop(Looper.java:135) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226) at java.lang.Thread.run(Thread.java:831) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372) ... 8 more Caused by: java.lang.NoSuchMethodError: No virtual method getActiveNotifications()[Landroid/service/notification/StatusBarNotification; in class Landroid/app/NotificationManager; or its super classes (declaration of 'android.app.NotificationManager' appears in /system/framework/framework.jar) at com.dieam.reactnativepushnotification.modules.RNPushNotificationHelper.getDeliveredNotifications(RNPushNotificationHelper.java:684) at com.dieam.reactnativepushnotification.modules.RNPushNotification.getDeliveredNotifications(RNPushNotification.java:239) ... 11 more

It's an issue with the SDK version with this line:
https://github.com/zo0r/react-native-push-notification/blob/master/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java#L727

I'm going to publish a fix ASAP.
Then you will be able to use the code you published but it will not work for Android SDK < 23 (Android M).

Regards,

Damn it. You're amazing man.
@Dallas62

Was this page helpful?
0 / 5 - 0 ratings