infobip / mobile-messaging-react-native-plugin

Mobile Messaging SDK plugin for React Native projects
24 stars 4 forks source link

Cannot receive tapped notification event when app is closed #61

Closed sunnylab96 closed 7 months ago

sunnylab96 commented 1 year ago

Hi! I can not receive tapped notification event when the app is closed. I'm using SDK 8.0.0 on Android 12, getting this error when tap on the notification message:

04-17 15:51:17.891 10157  6183  6457 D RNMobileMessaging: Will not migrate cryptor :
04-17 15:51:17.892 10157  6183  6457 W System.err: java.lang.ClassNotFoundException: org.infobip.mobile.messaging.cryptor.ECBCryptorImpl
04-17 15:51:17.892 10157  6183  6457 W System.err:  at java.lang.Class.classForName(Native Method)
04-17 15:51:17.893 10157  6183  6457 W System.err:  at java.lang.Class.forName(Class.java:454)
04-17 15:51:17.895 10157  6183  6457 W System.err:  at java.lang.Class.forName(Class.java:379)
04-17 15:51:17.895 10157  6183  6457 W System.err:  at org.infobip.reactlibrary.mobilemessaging.ReactNativeMobileMessagingModule.init(ReactNativeMobileMessagingModule.java:384)
04-17 15:51:17.895 10157  6183  6457 W System.err:  at java.lang.reflect.Method.invoke(Native Method)
04-17 15:51:17.896 10157  6183  6457 W System.err:  at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
04-17 15:51:17.896 10157  6183  6457 W System.err:  at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
04-17 15:51:17.897 10157  6183  6457 W System.err:  at com.facebook.jni.NativeRunnable.run(Native Method)
04-17 15:51:17.898 10157  6183  6457 W System.err:  at android.os.Handler.handleCallback(Handler.java:938)
04-17 15:51:17.899 10157  6183  6457 W System.err:  at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 15:51:17.899 10157  6183  6457 W System.err:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
04-17 15:51:17.899 10157  6183  6457 W System.err:  at android.os.Looper.loopOnce(Looper.java:201)
04-17 15:51:17.900 10157  6183  6457 W System.err:  at android.os.Looper.loop(Looper.java:288)
04-17 15:51:17.900 10157  6183  6457 W System.err:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
04-17 15:51:17.900 10157  6183  6457 W System.err:  at java.lang.Thread.run(Thread.java:920)
04-17 15:51:17.901 10157  6183  6457 W System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "org.infobip.mobile.messaging.cryptor.ECBCryptorImpl" on path: DexPathList[[zip file "/data/app/~~nr8CSaI7bVYmde_3fVICeA==/com.sunnylab-xa3piZpoYY3DfbCdMFaZYQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~nr8CSaI7bVYmde_3fVICeA==/com.sunnylab-xa3piZpoYY3DfbCdMFaZYQ==/lib/x86_64, /data/app/~~nr8CSaI7bVYmde_3fVICeA==/com.sunnylab-xa3piZpoYY3DfbCdMFaZYQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
04-17 15:51:17.902 10157  6183  6457 W System.err:  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
04-17 15:51:17.903 10157  6183  6457 W System.err:  at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
04-17 15:51:17.903 10157  6183  6457 W System.err:  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
04-17 15:51:17.904 10157  6183  6457 W System.err:  ... 15 more
riskpp commented 1 year ago

Hi @sunnylab96 could you please put full stack trace and try to reproduce this scenario with Example app.

This error you provided, just means that cryptor migration isn't setup, just informative one, however we might remove it if it confuses.

Let me also clarify what does it mean "I can not receive tapped notification event when the app is closed"? Does it mean that app was swiped off and then user tapped on received notification and event "notificationTapped" wasn't received?

I'll need also the code for how are you calling init method and subscribing to notifications.

sunnylab96 commented 1 year ago

Hi @riskpp , yes, I could not receive the notificationTapped event when swiped off the app, here is how I initiate the mobile SDK and subscribe for the notificationTapped event:

  if (Platform.OS === 'ios' || !configuration.geofencingEnabled) {
    mobileMessaging.init(
      {
        applicationCode:
          'xxxxxxxxxxxxxxxx',
        ios: {
          notificationTypes: ['alert', 'badge', 'sound'],
          logging: true,
        },
        defaultMessageStorage: true,
        inAppChatEnabled: true,
        geofencingEnabled: false,
      },
      () => {
        console.log('Mobile messaging initialized');
        mobileMessaging.subscribe('notificationTapped', message => {
          console.log('Notification tapped event received!');
        });
      },
      error => console.log('An error occur: ', error),
    );
  }
};
riskpp commented 1 year ago

You can try to subscribe earlier, as done in Example app and where are you calling mobileMessaging.init ?

riskpp commented 9 months ago

@sunnylab96 did the answer help you? We are going to close it in a week if no activity

tjuric commented 7 months ago

Closing due to inactivity.