I don't understand how to use AdvancedPlatformDelivery-Version to send push notifications to a registered iOS/Android device. I want to send a message with the Title: "Welcome message" and the message body "Hello "+ displayname of the Player. How can I do that?
Can I use one cloud script version for Android and iOS or is it necessary to create two different cloud scripts(one for iOS and one for Android)?
My cloud script:
handlers.Welcome = function (args, context) { try { jsonObjectIOS = { "customData" : customDataString, // include any additional data here "content-available": 1 }; let jsonStringIOS = JSON.stringify(jsonObjectIOS); let plattformIOS = "ApplePushNotificationService"; let pushNotificationResult = server.SendPushNotification ({ Recipient: recipientPlayFabId, AdvancedPlatformDelivery: [ { Json: jsonStringAndroid, Platform: plattformAndroid }, { Json: jsonString, Platform: plattformIOS } ] }); server.SendPushNotification({ Package : { Message : "Hello", Title: "Welcome message" }}); } catch (ex) { // Target player has not registered for Push Notifications } }
client application code:
string Errormsg = ""; private async Task SendPushNotification() { var result = await PlayFabClientAPI.ExecuteCloudScriptAsync(new ExecuteCloudScriptRequest() { FunctionName = "Welcome", GeneratePlayStreamEvent = true }); if (result.Error != null) Errormsg = result.Error.Error.ToString(); else Errormsg = "Sending Push notification successful?"; }