question

michael-2 avatar image
michael-2 asked

Push Messages and Prime31 Android Receiver

I'm setting up server side push through PlayFab in our Unity project and have run into a problem. I got the iOS side working fine but hit an issue with Android. We're not able to use the supplied PlayFab Receiver Plugin as it would bump us to min target SDK of 21 (we wish to stay supporting 16) as well as blows our max dex count, mainly as the plugin seems to include the appcompat.aar which adds 5k+ calls.

I tried to use the Prime31 receiver but think the problem is the format of what PlayFab sends for the message and what Prime31 is expecting is different.

I can successfully get the user registered to GCM as well as to PlayFab. I go to the user's ID on the PlayFab dash and send them a test push via that. The logs on my device show that I receive a push and a notification does appear however the title and message just say:

Default Title (title parameter not sent with notification)

Default Subtitle (subtitle not sent with notification)

Here is an example of the Custom JSON I am sending via the PlayFab dash:

{ "message": "here is a message", "smallIcon": "small_icon", "title": "This is a title", "collapse_key": "do_not_collapse", "tickerText": "Ticker text here...Ticker text here...Ticker text here", "sound": "1", "subtitle": "This is a subtitle", "vibrate": "1", "from": "589644589374", "largeIcon": "large_icon" }

and here is what I think PlayFab usually sends:

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

Has anyone successfully sent a push from PlayFab to the Prime31 receiver? Any help would be much appreciated.

Cheers

10 |1200

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

michael-2 avatar image
michael-2 answered

I returned to trying to add push to our game after shelving it for awhile and managed to get it all working this time. I'm using Playfab to send the push messages and the Prime31 Google Cloud Messaging receiver. This was required for us as it allowed us to remain on API16 instead of jumping up to API19 (We would have lost 28% of our current userbase otherwise)

Not much additional is required to get this setup working except for this. The push data Playfab sends is different to what Prime31 is expecting so a little translation is required, thankfully Prime31 allows you to specify alternate keys now.

To get your message to appear in code you need to do this since playfab has it in a "default" tag whilst prime31 is expecting a "subtitle" tag.

 GoogleCloudMessaging.setPushNotificationAlternateKey ("subtitle","default");

We couldn't get a title for the push to come down correctly from Playfab, however that wasn't a big deal for us since we can just "hard-code" a title to be displayed if none is found in the push:

 GoogleCloudMessaging.setPushNotificationDefaultValueForKey ("title", "Game News!");

That's it, title and message of the push are now displaying correctly on Android. iOS of course doesn't need any changes and just works out of the box.

10 |1200

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

brendan avatar image
brendan answered

There's actually a fairly detailed discussion on the question of version support in this thread: https://community.playfab.com/questions/10840/android-plugin-upgrade-discussion.html. We'll also be updating the documentation shortly to clarify that we support 21-25.

We don't support the Prime31 receiver directly, but if anyone else has experience working with it, we'd love to hear your experiences as well.

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.

michael-2 avatar image michael-2 commented ·

Hi @Brendan.

It certainly looks like my error is a mis-match of JSON formatting between what Playfab sends and what Prime31 is expecting. As a test we sent a push message via Google servers directly.

Sent to https://android.googleapis.com/gcm/send

Our Json Body Was:

{
    "registration_ids" : ["APA91bEzspHzl50lfkrOdasOuCz1Am5NnGyCzMk_YhyL-bsxRjwRJ9VuTLEGmWz1_J6-sPghL8M3Wp8-vX3curSMMS3V1rnLl7UlSYXWHsN3omBsTpPQovWOdlxaVKaOkPalJe9UW6K-"],
    "data":{
        "message": "here is a message. message: 2014-09-23 14:13:35",    
        "smallIcon": "small_icon",    
        "title": "Dogs",    
        "collapse_key": "do_not_collapse",    
        "tickerText": "Rainbows Rainbows Rainbows Rainbows Rainbows Rainbows Rainbows Rainbows Rainbows ",    
        "sound": 1,    
        "subtitle": "A subtle subtitle",    
        "vibrate": 1,    
        "smallIcon" : "notify_icon",
        "largeIcon": "notify_icon"
    }
}

This appears on our device just fine, so I've confirmed that our client side setup is correct. Is there anyway we can send a push message via Playfab in this format?

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.