question

Denis Bychkovskiy avatar image
Denis Bychkovskiy asked

server.SendPushNotification with AdvancedPlatformDelivery on iOS Always fails

I am trying to send a notification via Cloud Script for an iOS app. Notifications are configured, "SendPushNotificationFromTemplate" works as expected, but in some cases I need to replace the text inside the message. You cannot add parameters to Template notifications.

If I specify only the "Message" field in the request, the notification will come without a header and without sound. I tried using the "Package" field, but on iOS the notification comes with no sound and no header, and there is a huge JSON in the message instead of text.

I realized that I needed to use "AdvancedPlatformDelivery", but dozens of my attempts ended up with an error log, and I can't figure out what I was doing wrong

The log looks like this:

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


If I add an additional field to the request, for example "Message", no matter with what content, I get another error log:

"Only one of the following properties can be defined: Message, Package, AdvancedPlatformDelivery"

I need to send a notification with title, text, and so that it comes with sound on iOS via a cloud script. I have already looked through many similar topics, but for some reason none of the solutions worked for me ... I can't find the cause of the problem for more than a day... Here is my Cloud script:

handlers.SendCustomPushNotification = function (args, context){
                

let TargetUserID = args.targetUserID;
let Title = args.title; let Message = args.message; var IOSPayload = { "alert" : { "title" : Title, "body" : Message }, "badge" : 1, "sound" : "default" }; server.SendPushNotification( { Recipient: TargetUserID, AdvancedPlatformDelivery: [ { Platform:"ApplePushNotificationService", Json: JSON.stringify(IOSPayload) } ], TargetPlatforms: [ "ApplePushNotificationService" ] });

}


And log

"Message": "PlayFab API request error",
        "Level": "Error",
        "Data": {
          "api": "/Server/SendPushNotification",
          "request": {
            "Recipient": "88DF2E5369B3F3C0",
            "AdvancedPlatformDelivery": [
              {
                "Platform": "ApplePushNotificationService",
                "Json": "{\"alert\":{\"title\":\"Testing title\",\"body\":\"Testing message\"},\"badge\":1,\"sound\":\"default\"}"
              }
            ],
            "TargetPlatforms": [
              "ApplePushNotificationService"
            ]
          },
          "result": null,
          "apiError": {
            "code": 400,
            "status": "BadRequest",
            "error": "PushServiceError",
            "errorCode": 1095,
            "errorMessage": "iOS Push Notification Failed: ValidationError 1 validation error detected: Value null at 'message' failed to satisfy constraint: Member must not be null",
            "errorHash": null,
            "errorDetails": null
          }
        }

I tried additionally specifying AdvancedPlatformDelivery for Android, but was getting exactly the same error...
What am I doing wrong?

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

Citrus Yan avatar image
Citrus Yan answered

The code you provided is correct, seems that it's caused by a temporary issue from our side. I noticed that you also opened a ticket regarding the same issue, and our engineers are working on this with you, if you have further questions, please follow up in that channel, thanks!

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.

Citrus Yan avatar image Citrus Yan commented ·

For anyone who runs into the similar issue, it could be that your title is still on an earlier version of our push notification code. If you believe that's the case for your issue, please contact us via this forum or creating support tickets so that we can take a look for you.

0 Likes 0 ·
timbola avatar image
timbola answered

Hi, is there any update on this issue? I've get exactly the same error as the topic poster. Using postman.

When using 'Message' instead of ''AdvancedPlatformDelivery", the push notification works fine on iOS.

Hope you can help.

{
    "code": 400,
    "status": "BadRequest",
    "error": "PushServiceError",
    "errorCode": 1095,
    "errorMessage": "iOS Push Notification Failed: ValidationError 1 validation error detected: Value null at 'message' failed to satisfy constraint: Member must not be null"
}

2 comments
10 |1200

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

Denis Bychkovskiy avatar image Denis Bychkovskiy commented ·

@Timbola Hello! Sorry for the delay. The code from my question is correct. Try using it. In my case, the problem was solved only through support. Something was wrong with my title, as Citrus Yan wrote. After some experimentation, they fixed the problem. My code hasn't changed and now works.

1 Like 1 ·
timbola avatar image timbola Denis Bychkovskiy commented ·

Thanks, I will contact support!

0 Likes 0 ·
timbola avatar image
timbola answered

@Citrus Yan can you help me out? I've upgraded my account to the standard plan, but it will only be effective from 1 January. Hope you can help to fix this problem for my title. Thanks!

7 comments
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 commented ·

May I know your title id? And, please submit a support ticket with your title id provided regarding this issue via SUPPORT TICKET SUBMISSION if possible.

0 Likes 0 ·
timbola avatar image timbola Citrus Yan commented ·

Thanks for your answer. I've upgraded my account to get support, but it will start on 1st of January.. so I can't submit a ticket now. How can I send my title id without showing it in this comment?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan timbola commented ·

Actually, title ids aren't considered as very sensitive info, you can just post yours here. And, once we received your id, we can delete the comment for you.

1 Like 1 ·
Show more comments

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.