question

dev4rassees avatar image
dev4rassees asked

SendPushNotification AdvancedPlatformDelivery on Android always fails,PlayFab pushnotifications

private void SendPushNotification(string id)
    {
        var request = new SendPushNotificationRequest();
        request.Message = "Test message";
        request.Recipient = id;
        request.Subject = "Received the message";
        

        request.AdvancedPlatformDelivery = new List<AdvancedPushPlatformMsg>
        {
            new AdvancedPushPlatformMsg
            {
                GCMDataOnly = false,
                Json = "{\"name\":\"john\",\"age\":22,\"class\":\"mca\"}",
                Platform =PlayFab.ServerModels.PushNotificationPlatform.GoogleCloudMessaging
            }
        
        };

        request.TargetPlatforms = new List<PlayFab.ServerModels.PushNotificationPlatform> {PlayFab.ServerModels.PushNotificationPlatform.GoogleCloudMessaging};

        PlayFabServerAPI.SendPushNotification(request, (s) => {Debug.LogError("Sent");}, (e) => {Debug.LogError("error" + e.ErrorMessage);});
    }


Whats wrong with this piece of code ? When send this push notification along with "AdvancedPlatformDelivery" , its not delivering. But when remove it, its working as usual. Kindly suggest me whats wrong with this code?
,
private void SendPushNotification(string id)
    {
        var request = new SendPushNotificationRequest();
        request.Message = "Test message";
        request.Recipient = id;
        request.Subject = "Received the message";
        

        request.AdvancedPlatformDelivery = new List<AdvancedPushPlatformMsg>
        {
            new AdvancedPushPlatformMsg
            {
                GCMDataOnly = false,
                Json = "{\"name\":\"john\",\"age\":22,\"class\":\"mca\"}",
                Platform =PlayFab.ServerModels.PushNotificationPlatform.GoogleCloudMessaging
            }
        
        };

       
        request.TargetPlatforms = new List<PlayFab.ServerModels.PushNotificationPlatform> {PlayFab.ServerModels.PushNotificationPlatform.GoogleCloudMessaging};

        PlayFabServerAPI.SendPushNotification(request, (s) => {Debug.LogError("Sent");}, (e) => {Debug.LogError("error" + e.ErrorMessage);});
    }





What's wrong with this piece of code ? When try to send push notification, i am always getting  this error "Invalid input parameters". But when i remove the "request.AdvancedPlatformDelivery", push notifications are delivering properly. But i need to send the json part. Kindly suggest me what wrong with this piece of code ? 
Push NotificationsandroidPlayer Inventory
10 |1200

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

1 Answer

·
Rick Chen avatar image
Rick Chen answered

When calling the SendPushNotification API, if the request body contains both “Message” and “AdvancedPlatformDelivery”, it will return error “InvalidParams" and a message saying "Only one of the following properties can be defined: Message, Package, AdvancedPlatformDelivery". Is this error you are receiving? When you use the “AdvancedPlatformDelivery”, could you please remove the “Message” property and try again?

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

dev4rassees avatar image dev4rassees commented ·

Thanks for your response. I fixed the issue. Its the same as you described. But there is no documentation stating this.

0 Likes 0 ·
dev4rassees avatar image dev4rassees commented ·

Thanks for your response. I fixed the issue. Its the same as you described. But there is documentation stating this.

0 Likes 0 ·
Rick Chen avatar image Rick Chen ♦ dev4rassees commented ·

I am glad that you fixed the issue. If you have any further questions, please feel free to ask.

0 Likes 0 ·

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.