question

freelancegordon avatar image
freelancegordon asked

Firebase Cloud Messaging Data Payload

Hi guys,

I'm using a plugin for Android push notifications on unity called UTNotifications. But I've been made aware that they only support FCM data pushes, much to my annoyance.

Is there any way to find or set the exact payload structure that Playfab uses for it's android push notifications? As the plugin looks in 'data/' for the title and message of the push, I'm unsure if I can use this plugin to receive notifications from playfab.

Would really appreciate guidance on this as I've not done Android pushes before.

Cheers

Push Notifications
1 comment
10 |1200

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

freelancegordon avatar image freelancegordon commented ·

I'm puzzled as to why a lot of the documentation around push notifications seem to be 404 today. I thought if I couldn't get UTnotifications to work I might use the Playfab android push plugin I saw mentioned in the unity plugin. But the Github repo for it is 404'ing today, along with the push notification documentation on the playfab site.

0 Likes 0 ·
brendan avatar image
brendan answered

Sorry for the confusion - we just updated the site, and it appears that the Search bar is returning outdated links. The docs you need are listed on our Tutorials page, but here are the exact links:

https://api.playfab.com/docs/tutorials/push-notification-basics

https://api.playfab.com/docs/tutorials/push-notifications-for-android

I'm not sure what GitHub repo you're referring to, though - can you clarify that part?

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.

freelancegordon avatar image freelancegordon commented ·

Hi Brendan, thanks for the response!

The github repo I'm referring to is linked in your UnitySDK repo: https://github.com/PlayFab/UnitySDK under section 4 of the readme, it links to https://github.com/PlayFab/UnitySdkV0/tree/master/UnityAndroidPluginSource and mentions an android push plugin.

The developer of UTNotifications has informed me that I need to find out what payload format your push notifications are using, as it doesn't seem to be clear from the documentation whether they are using Notification, Data or Mixed payloads. UTNotification requires them to use Data payload format and to know the structure of that payload format to fetch the relevant information from the push, so I need to know if Playfab's push notifications are compatible or if I need to implement another android push notification solution.

Thanks again.

0 Likes 0 ·
brendan avatar image brendan freelancegordon commented ·

It's a simple Data payload, but please note that the format (see the Android-specific doc on the site) must be correct.

0 Likes 0 ·
freelancegordon avatar image freelancegordon brendan commented ·

Thanks for clarifying, it's appreciated.

Unfortunately the docs seem to be 404'ing again, but I can't seem to figure out how to access the payload data via UTNotifications. The developer for UTNotifications said that the format I copied from those docs when they were available yesterday:

{ "Title": "Message from Game", "Icon": "open_chest", "Sound": "raw/open", "Message": "You've gained gold!", "CustomData": { "gold": "5", "currency": "G" } }

is not a valid payload format.

It seems to expect 'data/' followed by the path to the data in question. But I've tried 'data/Title' and 'data'/Message/Title' but neither worked.

0 Likes 0 ·
marcodoc avatar image
marcodoc answered

for now you can look at our plugin documentation on our repository.
https://github.com/PlayFab/UnitySDK/tree/master/PluginsSource/UnityAndroidPluginSource

In the scheduled push notifications area you can get the general idea of the format. However, do note that the scheduled attributes are not required and found in the "Message" attribute. Our plugin parses the entire payload for you.

I would also like to point out that the format for the message if sent from PlayFab is what you determine it to be when you configure it in PlayFab. What I mean for that is that if an action is set to send a notification, you can put JSON in the textarea and that is what will be sent.

Look at this file:
https://github.com/PlayFab/UnitySDK/blob/master/PluginsSource/UnityAndroidPluginSource/playfabunityplugin/src/main/java/com/playfab/unityplugin/GCM/PlayFabGcmListenerService.java

lines 49 - 58 , you'll see that we are grabbing the "Message" attribute and parsing it. From there our plugin grabs the Title, Icon, Schedule, Sound etc.. so if you are expecting all those attributes at the top level, it will be incorrect.

hope that helps.

p.s.
We are working on the redirect issue on the site, I do not have an ETA at this time.

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

freelancegordon avatar image freelancegordon commented ·

Thanks for the helpful response,

I've managed to get something to read from UTNotifications, data/default gives me the default message, which makes sense. Does that mean internally from Playfab when I choose to run a task and send a push, that it follows the 'multiple platforms' payload here: http://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-custommessage.html ?

If so that gives me somewhere to begin. Does this mean I should be able to access that data with data/GCM/Title ? It doesn't seem to work, though. I also tried data/GCM/data/message

{ "default": "This is the default message which must be present when publishing a message to a topic. The default message will only be used if a message is not present for one of the notification platforms.", "APNS": "{\"aps\":{\"alert\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\"} }", "GCM":"{\"data\":{\"message\":\"Check out these awesome deals!\",\"url\":\"www.amazon.com\"}}", "ADM": "{ \"data\": { \"message\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\" }}" }

UTNotifications doesn't seem to be able to find data/GCM if that's the format you're adhering to.

0 Likes 0 ·
freelancegordon avatar image freelancegordon commented ·

I've ripped out UTNotifications and tried replacing it with the Playfab android plugin.

Problem now is that although I'm able to receive the push token successfully, I can't send any as my app isn't set up with GCM it's set up with Firebase. It doesn't seem like the plugin supports FCM right now.

0 Likes 0 ·
brendan avatar image brendan freelancegordon commented ·

Actually, it does work with FCM - have a look at this video for more info:

https://www.youtube.com/watch?v=f6RFXrlSlmw

0 Likes 0 ·
freelancegordon avatar image freelancegordon brendan commented ·

Thanks for the pointer, that's perfect. I got it working now and we're happily submitted :)

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.