SirKnigget
SirKnigget

Reputation: 3644

Using Facebook Achievement API in Android

I understand that this might seem like a generic question, but it seems to be insanely difficult to find information on the topic, so I would appreciate a complete example \ guide \ source code link if it exists somewhere.

I am developing an Android game and would like the integrate Facebook Achievements. All I want is to share achievements when the user completes a certain puzzle - so it will show in their feed and link to my app.

This is the official documentation from facebook: https://developers.facebook.com/docs/games/achievements

Now, when I initially started integrating the Facebook SDK, I thought that reading\writing achievements is a very simple matter (which is true for most game services, like Google Play).

But it seems like I need to go a very long way - create some website with HTML metadata so facebook can read from it, define new Open Graph objects, etc. - which seems like way too much work for such a feature.

My question is simple - is there any clear, user-friendly guide or example that shows how to use Facebook achievements with an Android game? Preferably, without having to host my own website with HTML metadata.

The Facebook docs are obviously a nightmare. I've never struggled like that with an SDK that claims to offer such a simple service. (especially when compared to equivalent services like Google Play Game Services).

Upvotes: 3

Views: 1280

Answers (1)

SirKnigget
SirKnigget

Reputation: 3644

I found my own answer.

    • In order to avoid storing meta-tags in my own server, I use Facebook's Object API to create app-owned "achievement" objects (My own custom type, not the built-in "game achievement"). It can be done with the Object Browser, using your admin account: https://developers.facebook.com/tools/object-browser
    • The only thing I need to host are images (so I can populate the image URL field). If I wished to avoid even that, I could directly upload images to Facebook from my mobile app and connect them to a user-owned object (but not app-owned object).
    • Now, I use my own custom action for the achievements. I called it "Solve" (solve a puzzle), and it has a custom ID integer field for my own use. I created a custom story that connects the "Solve" action to my "Puzzle" (achievement) object.
    • The action is defined as "unique" (no more than one action-object pair) - so it really behaves like an achievement.
    • The story (action-object) can be published using the Graph API: https://developers.facebook.com/docs/android/open-graph (Of course, the same goes for other platforms)
    • The action can be marked as "explicitly shared" (https://developers.facebook.com/docs/android/open-graph#apicalls-step4) in order to directly show it on the player's timeline.
    • In order to read the player's existing achievements, I use a Graph API request to read the current actions of a certain type from the player's profile. I don't need additional permissions for that: https://developers.facebook.com/docs/opengraph/using-actions/v2.2#read
    • Since I attached my custom ID property to each action, I can easily identify the player's past actions as related to my game's achievement IDs.

Upvotes: 2

Related Questions