Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Kim Strasser · Jul 23, 2019 at 12:51 PM · Push Notifications

How can I use AdvancedPlatformDelivery to send push notifications?

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?";
}
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

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.

Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kim Strasser · Jul 25, 2019 at 11:57 AM 0
Share

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.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Some push notifications failing to send 1 Answer

    Unity Android Push Notification Icon White T.T 1 Answer

    ProfileAPI SetProfileLanguage randomly returning NotAuthorized 1 Answer

    Receive incoming webhooks from zendesk 1 Answer

    How to get the position (rank) of the leaderboard when you reset the leaderboard. And send a notification with rank? 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges