question

Georgi Darakev avatar image
Georgi Darakev asked

Sending Push Notifications on iOS with title and message from Cloud Script

Hi,

I am trying to set up push notifications with a title and a message from CloudScript.

Example:

I tried a few different ways, but I wasn’t able to get any of them to work properly.

I tried following the example from the Quickstart docs:

https://docs.microsoft.com/en-us/gaming/playfab/features/engagement/push-notifications/quickstart

server.SendPushNotification({
	Recipient :currentPlayerId,
	Package : {Message :"Message Text",Title:"Title Text"}
});

The result seems to be showing a dump of the JSON data in the message.

I tried following these docs:

https://docs.microsoft.com/en-us/rest/api/playfab/server/account-management/sendpushnotification?view=playfab-rest#sendpushnotificationrequest

server.SendPushNotification({
        Recipient : currentPlayerId,
        Subject : "Title Text",
        Message : "Message Text",
    });

If I try using the Message and Subject parameters I only receive the message without the title.

I also tried following this forum post and use the AdvancedPlatformDelivery.

https://community.playfab.com/questions/46942/serversendpushnotification-with-advancedplatformde.html

 var IOSPayload = 
    {
        "alert" : 
        {
            "title" : "Title Text",
            "body" : "Message Text"
        },
        "badge" : 0,
        "sound" : "default"
    };


    try{
    server.SendPushNotification(
    {
        Recipient: currentPlayerId,
        AdvancedPlatformDelivery:
        [
            {
                Platform:"ApplePushNotificationService",
                Json: JSON.stringify(IOSPayload)
            }
        ],
        TargetPlatforms:
        [
            "ApplePushNotificationService"
        ]

    });

It seems that I am getting the same error as the post:

"errorMessage": "iOS Push Notification Failed: ValidationError 1 validation error detected: Value null at 'message' failed to satisfy constraint: Member must not be null",

Based on the forum responses it appears to be an internal Playfab issue.

Please advise on how I should do this?

CloudScriptPush Notifications
img-0033.png (39.7 KiB)
img-0034.png (59.0 KiB)
10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

May I have your title id? And, regarding the "...ValidationError" error, do you have access to support tickets? If so, please create one and one of our support engineers will help you with that.

10 |1200

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

Aleksey avatar image
Aleksey answered

@darakevg have you find a solution? Because i hame the same problem with text without Subject. But if I use template notifications everything just works fine.

,

@darakevg Have you find a solution? Me to have the only message without "Subject", but if I use template notification everything just working fine. Dont know where is a probled?

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.

Seth Du avatar image Seth Du ♦ commented ·

Thanks for the feedback. In case there is no response, please continue to find support in the new thread you have posted.

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.