question

tedbom avatar image
tedbom asked

Unity RemoteNotification userData empty where I expect CustomData

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

unity3dPush Notifications
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
comc avatar image
comc Deactivated answered

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.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tedbom avatar image tedbom commented ·

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:

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW1

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?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.