Hello,
Currently we are trying to implement Remote Push Notifications through CloudScript.
We are executing the following CloudScript function extending the basics article:
var testObject = { "TestKey" : "TestValue" }; var jsonString = JSON.stringify(testObject); try { server.SendPushNotification({ Recipient : currentPlayerId, Package : { Message : "Test challenges you for a battle!", Title: "You have been challenged", CustomData : jsonString }, }); } catch (ex) { // Target player has not registered for Push Notifications }
On Android we properly receive the CustomData in the MessageReceivedEventArgs.Message.Data field.
However on iOS with Unity's built-in RemoteNotification I can't seem to find the Custom Data anywhere. The alertBody is present, but the userData Hashtable is empty.
Are we missing something or are we suppose to use a custom plug-in/native implementation?
Are we perhaps suppose to use AdvancedPlatformDelivery instead of Package to get custom data to iOS users?
Cheers,
Ted
Answer by comc · May 22, 2018 at 08:41 PM
Yes, you can use AdvancedPlatformDelivery if you know the structure of the JSON you should be receiving from the device. We have added a work task to support it properly.
Thank you for the reply,
I have tried AdvancedPlatformDelivery, however it seems that for iOS it wraps the AdvancedPushPlatformMsg.Json value in the aps dictionary. Meaning that I can only supply it with valid aps keys as documented here:
If I read the documentation correctly to supply additional data, I would have to add data in addition to the "aps" dictionary. This is an example from Apple's documentation.
{ "aps" : { "content-available" : 1 }, "acme1" : "bar", "acme2" : 42 }
Of course I can try to write my own native solution to parse the data manually, but if possible I would like to avoid that. Would it be possible to get a confirmation for if that is how the AdvancedPlatformDelivery currently works for iOS?
FCM ios push notifications aren't working (android does) for Unity 4 Answers
Push Notifications On Unity with Firebase 1 Answer
Push notification scheduling not working? 3 Answers
Scheduled notifications - How to call 1 Answer
Is it possible to store the content of a push notification in title player account? 1 Answer