Closed AngeloLazzari closed 4 years ago
here is a pastebin of the VERBOSE log since start of the app, and crash of it due to the error parsing the returned payload.
thank you very much
Howdy, Take a look at our docs here.
You may be missing the body
parameter.
// Called when your app is in focus and a notificaiton is recieved.
// The name of the method can be anything as long as the signature matches.
// Method must be static or this object should be marked as DontDestroyOnLoad
private static void HandleNotificationReceived(OSNotification notification) {
OSNotificationPayload payload = notification.payload;
string message = payload.body;
print("GameControllerExample:HandleNotificationReceived: " + message);
print("displayType: " + notification.displayType);
extraMessage = "Notification received with text: " + message;
}
Hope that helps.
Hi @rgomezp thank you for you reply, really apreciated. the body property does not work for us because we need to take the payload.additionalData and on it get the noticationType = additionalData["type"].ToString(); notificationData = additionalData["data"].ToString(); to perform our app logic.
the problem totally there, I mean, for IOS the payload additionalData has a JSON WRONG like in the this image:
and on Android, SAME CODE in app and backend, the payload comes CORRECTLY like this other image:
So, parsing like JSON the IOS goes into a parsing error.
I checked the oneSignal messages for both projects and the sent messages are the same.
thank you very much! Angelo
Hi, please, I need on this, I tried to get rid of it but no way.... , thank you very much Angelo
Hi, we found a workaround to fix it: In the ONE SIGNAL API call from out backend, just added a \ before every " present into the JSON we sent into the additionaldata field, doing this, IOS now is working correctly, as Android did before, without the workaround.
So, before we sent: {"type":"keepalive","data":{"customerCode":"aaa","readerCode":"1","timestamp":"2020-09-02 08:21:48","online":true}}
and now we send {"type":"keepalive","data":"{\"customerCode\":\"aaa\",\"readerCode\":\"1\",\"timestamp\":\"2020-09-02 08:21:48\",\"online\":true}"}
I still think this should be fixed on the OneSignal Xamarin SDK, i mean, the two platform should work the same way.... no?
thank you very much Angelo
Howdy, I'm glad you were able to resolve! We will look into whether we can implement a permanent solution. This will be tracked internally.
Enjoy!
Description: Hi, I have all software stack and library update to the last version: Visual Studio and onesignal libraries. I have a xamarin form Android and Ios app, all is working perfectly on Android: when the notification is received the notification payload is parsed correctly, i mean, the JSON is correctly loaded into the payload variable with the code line:
that is the first line of the function:
if you check out the visual studio inspector image here you can see the additionaData value having the correct value
Problemas comes when the same notification is parsed from an iphone, so same project, same code, but different parsing into the "OSNotificationPayload payload" variable ... as you can see from the inspector image, the additionaData contains spaces and is not like the ANdroid versione....
this problem cause an error of the app when I try to parse the JSON content...
It is a normal behaviour?
thank you very much