universal-tools / UTNotificationsFeedback

7 stars 0 forks source link

OnNotificationClicked and OnNotificationsReceived not working if app was not open when notification received #91

Closed abhaykap closed 5 years ago

abhaykap commented 5 years ago

Hello, We have recently upgraded the UTNotification plugin to 1.7.3 and after that, we started having this issue: When we send Push notifications to our app the notification appears in the phone and when we open the app from by clicking the notification we received this issue:

We are testing on:

yuriy-universal-ivanov commented 5 years ago

Hi @abhaykap ,

What you describe look like typical symptoms of invalid FCM data payloads, specifically payloads containing a "notification" node. Please carefully read section Push Notifications Payload Format/FCM of the manual, particularly its notes.

Please let me know if in fact your FCM payloads are fine, and this is something different. In that case, I'd need your sample complete FCM json payload, and how you subscribe to OnNotificationClicked/OnNotificationsReceived, how you initialize UTNotifications.Manager and whether you ever clear all notifications/reset badge number, and if so, then when and how.

Best regards, Yuriy, Universal Tools team.

abhaykap commented 5 years ago

Hello Yuriy,

Abhay

yuriy-universal-ivanov commented 5 years ago

@abhaykap ,

Here you go: 'notification': {'title': 'ATest', 'body': 'ATest1'}. That's the issue. Please, please read the manual.

abhaykap commented 5 years ago

ok.

Reading through the manual and seems like having {'notification': {'title': 'ATest', 'body': 'ATest1'}} in the data is the issue, right? If so, have some question. Why does putting this causing issue? since this has been there since long in our payload and it was working before. also, why it works when the app is open at the time of receiving notification?

abhay

yuriy-universal-ivanov commented 5 years ago

@abhaykap

The issue with "notification" node in the payload is due to handling this type of FCM messages by Google Play Services of Android OS itself, instead of delivering them to the application, unless the app is running. This behavior is standard for FCM, so as soon as you started using it, it should have behaved the same way (though older versions of Google Play Services could maybe not support that).

So, if the app is running or there is no "notification" node in the payload, the message is handled by UTNotifications' native plugin, so supporting handling clicked/received messages, applying icons settings and so on. Otherwise, the message is handled by Android, so nothing of the above works correctly.

abhaykap commented 5 years ago

Thanks Yuriy for answers. Removing the {'notification': {'title': 'ATest', 'body': 'ATest1'}} from payload works like charm :)

yuriy-universal-ivanov commented 5 years ago

@abhaykap Glad to know that!