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?"; }
Answer by SethDu · Jul 25, 2019 at 07:17 AM
We are still working on the documentation on AdvancedPlatformDelivery but I cannot tell the ETA and still, feel free to post a Feature Requests thread on corresponding forum.
Hence, we suggest you to use the Push Notification Template Feature. You may find push notification template at [Game Manager] ->[Content]. It can handle not only different platforms but also multiple languages. However recently we are experiencing unknown issues with Push Notification Template and I will keep you informed if there is any fix or updates.
Have you tried to send notification via AdvancedPlatformDelivery? If it is Android, according my experience of testing, the data sent via this method will not automatically pop up a notification, but you are able to receive all the data in onReceive method. You may manually craft an notification in the client.
I don't know how to use AdvancedPlatformDelivery. For example, I don't know how to create the client application code to call the cloud script. I will wait on the documentation. In the meanwhile, I use the Package-Version of SendPushNotification: https://community.playfab.com/questions/31757/i-dont-receive-my-cloud-push-notifications.html
In addition, I will try the template feature because I need push notifications in different languages.