1

When receiving data message from server, this error log is display:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.sample.test, PID: 30964 java.lang.RuntimeException: Unable to start service com.huawei.hms.rn.push.remote.HmsPushMessageService@d69f855 with Intent { act=com.huawei.push.action.MESSAGING_EVENT pkg=com.sample.test (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4683) at android.app.ActivityThread.access$2900(ActivityThread.java:296) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2259) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:213) at android.app.ActivityThread.main(ActivityThread.java:8178) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference at com.huawei.hms.rn.push.logger.HMSLogger.setupEventMap(HMSLogger.java:292) at com.huawei.hms.rn.push.logger.HMSLogger.(HMSLogger.java:78) at com.huawei.hms.rn.push.logger.HMSLogger.getInstance(HMSLogger.java:95) at com.huawei.hms.rn.push.remote.HmsPushMessageService.onMessageReceived(HmsPushMessageService.java:35) at com.huawei.hms.push.HmsMessageService.a(HmsMessageService.java:185) at com.huawei.hms.push.HmsMessageService.onStartCommand(HmsMessageService.java:131) at com.huawei.hms.rn.push.remote.HmsPushMessageService.onStartCommand(HmsPushMessageService.java:90) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4663) at android.app.ActivityThread.access$2900(ActivityThread.java:296)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2259)  at android.os.Handler.dispatchMessage(Handler.java:107)  at android.os.Looper.loop(Looper.java:213)  at android.app.ActivityThread.main(ActivityThread.java:8178)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
Jeffy Lee
  • 87
  • 2
  • 9

3 Answers3

1

This problem is a known bug and it has been rectified already. Please update React Native Push Plugin to the latest version 5.0.2.301 here.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
1

Version 5.0.2.301 solved my issue working with react-native@^0.63.4. But it doesn't work with the latest version of the plugin available today (5.1.1-301).

@shirley FYI

Walter Devia
  • 55
  • 1
  • 1
  • 7
  • hi Walter Devia,thank you for your feedback,could you please provide your complete log, so that we can analyse your problem. You can get the complete log from the following steps. The procedure for capturing logs is as follows: 1. Run the following command to connect to the device: adb logcat –v time > D:\hwpush.log 2. Reproduce the fault. 3. Press Ctrl+C to complete log capture. – zhangxaochen May 06 '21 at 08:18
0

It seems your are using data messages, if yes tell me how you get data from notification? EX: In this code we are receiving "id" data message which we post from console or server:

   override fun onMessageReceived(message: RemoteMessage?) {
    Log.i("OnMesageReceived", "onMessageReceived is called");

    //data notification -get data
    val id = message!!.dataOfMap["id"]

}

  • I am able to get the data by using "message.getData()": @Override public void onMessageReceived(RemoteMessage message) { Log.w(TAG, "** onMessageReceivedData **" + message.getData()); Log.w(TAG, "** onMessageReceived **"); HMSLogger.getInstance(this).sendPeriodicEvent("onMessageReceived"); HmsMessagePublisher.sendMessageReceivedEvent(message); } – Jeffy Lee Oct 06 '20 at 08:54