question

arda avatar image
arda asked

iOS Push Notification CustomData is Empty

Hi, I'm trying to send a push notification to an iOS device. The code below is working perfectly for Android devices but on iOS MessageReceivedEventArgs reference e.Message.Data returns empty. e.Message.Notification.Body and e.Message.Notification.Title is working as expected and they are not empty. Also, notification is receiving from the device without a problem. Only problem is CustomData.

I already tried AdvancedPlatformDelivery, not working.

Thanks.

handlers.SendPushToFriend = function (args)
{
   
    var targetId = args.TargetId;
    var logArrayObject = [];
    var functionMessage = args.FunctionMessage;
    var splittedMessage = functionMessage.split("/");
    var obj = { playerID: currentPlayerId, fMessage : functionMessage };
    var myJSON = JSON.stringify(obj);
      

        // try to send push notification
        try {
            server.SendPushNotification({
                Recipient : targetId,
                Package : {
                    Message : splittedMessage[4] + " / " + splittedMessage[5] + " / " + splittedMessage[6] ,//currentPlayerId + "/" + functionMessage,
                    Title:  splittedMessage[2] + " " + splittedMessage[7],
                    CustomData: myJSON,
                }
            });
            
           
            
            
        } catch (ex) 
        {
            logArrayObject.push("error->" + ex.Message + " ID-->" + args.TargetId);
            // Target player has not registered for Push Notifications
        }
        
         return { returnLogValue: logArrayObject };
};





// FIREBASE C# CODE


private void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e)
    {
        lastMsg = "";
        messageData = "";
        if (e.Message.Data != null)
        {

            lastMsg += "DATA: " + PlayFabSimpleJson.SerializeObject(e.Message.Data) + "\n";
            Debug.Log("PlayFab: Received a message with data:");
            foreach (var pair in e.Message.Data)
            {
                Debug.Log("PlayFab data element: " + pair.Key + "," + pair.Value);
                if (pair.Value.Contains("GameInvitation"))
                {
                    messageData = pair.Value;
                }
                if (pair.Key.Equals("playerID"))
                {
                    senderPlayfabID = pair.Value;
                }

            }
        }
}
Push Notifications
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.

arda avatar image arda commented ·

Need help :/

0 Likes 0 ·

1 Answer

·
JayZuo avatar image
JayZuo answered

Currently, PlayFab only supports `aps` key for iOS Push Notification. Custom keys and values are not supported. If you do need the custom keys and values, please feel free to post a feature request for it.

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.

arda avatar image arda commented ·

Thanks for the info!

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.