Closed abhaykap closed 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.
Hello Yuriy,
Here is the sample payload: {'data': {'title': 'ATest', 'message': 'ATest1', 'text': 'ATest1', 'notification_data': '{"push_id": "5bea9397bf828b00096cc890", "url_action": true, "coins": 9999, "additional_action": {"name": "send_coins", "count": 9999}, "id": 0}'}, 'notification': {'title': 'ATest', 'body': 'ATest1'}, 'to': 'dLHtMY0fiog:APA91bG6V_fHx4cO1RHR4koePIxBDCcFBdQnb2dbP_lwfbpPtwBLD3KP24Z-5Y7e2y9u_NJcoVr9MAmBvta9bCaDuPMsdhmh3sT34hMEZPqBQpkhSFMW2bb2W-iM89SUrKfWDheHs82Q'}
We have written a notification manager class, there we simply call Manager.instance and hook the callbacks as below: private NotificationManager () : base () { Manager notificationsManager = UTNotifications.Manager.Instance; notificationsManager.OnSendRegistrationId += SendRegistrationId; notificationsManager.OnNotificationClicked += OnNotificationClicked; notificationsManager.OnNotificationsReceived += OnNotificationsReceived; //Let's handle incoming notifications (not only push ones) }
And we don't clear/reset notifications/badges in our code.
Abhay
@abhaykap ,
Here you go: 'notification': {'title': 'ATest', 'body': 'ATest1'}
. That's the issue. Please, please read the manual.
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
@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.
Thanks Yuriy for answers. Removing the {'notification': {'title': 'ATest', 'body': 'ATest1'}} from payload works like charm :)
@abhaykap Glad to know that!
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:
Android 8,
Unity 5.6.6f2
We are just working on Android at this time.
Abhay