function pushNotification(PlayFabId) { const applePayload = { "aps": { "alert": { "title": 'Game Request', "subtitle": 'Five Card Draw', "body": 'Do you want to play poker', }, "category": 'GAME_INVITATION' }, "gameID": '01FA1A786' } return server.SendPushNotification({ Recipient: PlayFabId, AdvancedPlatformDelivery: [ { Platform: "ApplePushNotificationService", Json: JSON.stringify(applePayload) } ] }); }
i used this code to push Notification with some Customize Data in CloudScript, but it fail with error message :
"iOS Push Notification Failed: ValidationError 1 validation error detected: Value null at 'message' failed to satisfy constraint: Member must not be null"
,const applePayload = { "aps": { "alert": { "title": 'Game Request', "subtitle": 'Five Card Draw', "body": 'Do you want to play poker', }, "category": 'GAME_INVITATION' }, "gameID": '01FA1A786' } return server.SendPushNotification({ Recipient: 'E01FA1A786D39B97', AdvancedPlatformDelivery: [ { Platform: "ApplePushNotificationService", Json: JSON.stringify(applePayload) } ] });
=====
I used this code in CloudScript to push a notification (IOS Devices), but it got an error :
"iOS Push Notification Failed: ValidationError 1 validation error detected: Value null at 'message' failed to satisfy constraint: Member must not be null"
Answer by Jay Zuo · Nov 02, 2020 at 09:44 AM
Currently, PlayFab only supports `aps` key. Custom keys and values are not supported. For iOS Push Notification, we will only need to provide the JSON string used as the value of "aps" key in the "Json" part of "AdvancedPlatformDelivery". For example:
"AdvancedPlatformDelivery": [ { "Platform": "ApplePushNotificationService", "Json": "{\"alert\":{\"title\":\"Game Request\",\"body\":\"Bob wants to play poker\",\"action-loc-key\":\"PLAY\"},\"badge\":5}" } ], "TargetPlatforms": [ "ApplePushNotificationService" ]
So, in your code, you can try to change the "applePayload" as the following to see if it works.
const applePayload = { "alert": { "title": 'Game Request', "subtitle": 'Five Card Draw', "body": 'Do you want to play poker' }, "category": 'GAME_INVITATION' };
If you do need the custom keys and values, please feel free to post a feature request for it.