LP-Messaging / Android-Messaging-SDK

LivePerson Android Messaging SDK
https://www.liveperson.com
28 stars 24 forks source link

NullPointerException when tapping notification #45

Open chris-wickens opened 6 years ago

chris-wickens commented 6 years ago

Occurs consistently when tapping a message received notification in version 2.9.2. I have not set anything in LPAuthenticationParams.

01-15 14:45:25.660 5400-6127/com.x.x E/AndroidRuntime: FATAL EXCEPTION: ConnectionStateMachine Process: com.x.x, PID: 5400 java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.liveperson.infra.LPAuthenticationParams.getHostAppJWT()' on a null object reference at com.liveperson.messaging.model.AmsAccount.isHostAppJWTExpired(AmsAccount.java:144) at com.liveperson.messaging.controller.AccountsController.isTokenExpired(AccountsController.java:82) at com.liveperson.messaging.controller.connection.ConnectionStateMachine$ConnectingState.actionOnEntry(ConnectionStateMachine.java:260) at com.liveperson.infra.statemachine.BaseStateMachine.changeState(BaseStateMachine.java:70) at com.liveperson.messaging.controller.connection.ConnectionStateMachine$DisconnectedState.visit(ConnectionStateMachine.java:878) at com.liveperson.messaging.controller.connection.connectionevents.ForegroundEvent.accept(ForegroundEvent.java:18) at com.liveperson.infra.statemachine.StateMachineExecutor$RunnableWrapper.run(StateMachineExecutor.java:26) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.os.HandlerThread.run(HandlerThread.java:61)

dvillacis94 commented 6 years ago

Can you send the how are you handling the notification? are you using FirebaseMessagingService? Can you share the onMessageRecived body you're using?

chris-wickens commented 6 years ago

We are still using GCM. I am calling the deprecated LivePerson.handlePush method which takes the message's intent extras, but converting it to a Map<String, String> and calling LivePerson.handlePushMessage does not fix the NPE. Our onMessage method and example of an incoming push message payload is below, apologies for the formatting.

@Override protected void onMessage(Context context, Intent intent) { String payload = intent.getExtras().getString("payload"); if (payload != null && payload.contains("conversationId")) { LivePerson.handlePush(context, intent.getExtras(), Core.getInstance().getLivePersonBrandId(), true); Intent unreadIntent = new Intent(BaseActivity.UNREAD_MESSAGE_ACTION); context.sendBroadcast(unreadIntent); } else { // Our own push message, handle it } }

Bundle[{google.sent_time=1516123482883, payload={"badge":5,"sequence":4,"conversationId":"34eb9941-2681-4f0f-b239-963d7245dbea","brandId":"x","backendService":"ams","originatorId":"56488935.216723214"}, from=549527446363, google.message_id=0:1516123482900330%8e2f1421f9fd7ecd, message=It: bzz}]

dvillacis94 commented 6 years ago

Can you change the

LivePerson.handlePush(context, intent.getExtras(), Core.getInstance().getLivePersonBrandId(), true)

to false, on the

LivePerson.handlePush(context, intent.getExtras(), Core.getInstance().getLivePersonBrandId(), false)

chris-wickens commented 6 years ago

If I do that a notification isn't shown, but it doesn't crash. The crash occurs when I tap the notification.