@3 Dreams Gaming, did you figure out the solution to this? I’m in the process of porting my iOS game to Android (and I’m using Kindle & Nook as the test device).
Without changing the iOS code (and even before I added the Android Key Hash), I could launch Facebook Sign In screen (just like how it works on my iOS device), and I am able to sign in and post to Facebook wall. However, unlike iOS version, when I fail to sign in (i.e., closing the sign in screen before completing it, for example), it doesn’t seem to return any feedback that the sign in failed. I’m wondering, maybe, what I need is the Android Key Hash to get this actually working properly – so I added it. But nothing changed after I generated new builds and installed the game on both Kindle and Nook. Maybe the reason why nothing changed is because it takes time before the Key Hash propagates throughout Facebook servers. (I hope that’s the only reason why it’s not working properly right now.)
Edit: I’m also using my own keystore (not the debug keystore) for my builds - if it makes any difference.
FYI, I’m using Daily Build 776 (on Mac).
Posted below is the code structure I’m currently using (in case it helps).
Anyhow, it would be great to hear how things went with you.
Naomi
Edit: I added the login error trap that was missing from the code structure below. By looking at Bob Dickinson’s helper module, I noticed what was missing. The very helpful helper module is found here: https://developer.anscamobile.com/code/facebook-helpersupport-module
Edit again: I needed to edit my code below to work on Android. In my case, the further edited code works perfectly on Android device (Kindle). However, it isn’t working properly on iOS device – but it may have something to do with the fact I haven’t released iOS version, and therefore, native iOS setting isn’t properly setup on Facebook dev page.
[lua]local facebook = require “facebook”
local MyAppID = “1234567890000” – this is fake, please use valid ID.
– this one works the way I want on my Kindle
local function myFBListener()
if ( “session” == event.type ) then
if event.phase ~= “login” then
– call a function to notify the user that log in failed
return
end
– This code posts an image and a message to the user’s Facebook Wall
local attachment = {
name = “My Game”,
link = “http://www.mygame.com”,
message = “Hello hello hello.”,
picture = “http://www.mygame.com/myImage.png”,
actions = json.encode( { name = “Learn More”, link = “http://www.mygame.com” } )
}
facebook.request( “me/feed”, “POST”, attachment )
– I decided to use “me/feed” instead of “me/photos” because I don’t want the image to be saved in the user’s Facebook album
elseif ( “request” == event.type ) then
if ( not event.isError ) then
– this block is executed upon successful facebook.request() call
– call a function to notify that the user has successfully posted on Facebook wall
else
– this block is executed when posting failed
– call a function to notify that posting to Facebook failed
end
end
end
facebook.login( MyAppID, myFBListener, {“publish_stream”} )[/lua] [import]uid: 67217 topic_id: 23635 reply_id: 99268[/import]