Facebook wall posting (again)

Sorry everyone, but I need some help…

I’ve tried everything that I can think of, but I cannot get the iOS version of my app to post to the user’s facebook wall. The Android version posts to the wall without problem.

I checked everything, read this 1000 times, but no luck. What happens is that a blank FB window opens, and returns back to my app.

Here’s my build.settings:

settings = {  
  
 orientation = {  
 default = "portrait",  
 supported = { "portrait", "portraitUpsideDown"}  
 },  
  
 iphone = {  
 components = {},  
  
 plist = {  
 UIApplicationExitsOnSuspend = false,  
 CFBundleURLTypes =  
 {  
 {  
 CFBundleURLSchemes =  
 {  
 "fb-----------", -- real fb app number here  
 }  
 }  
 },  
  
 -- For Android:  
  
 android =  
 {  
 versionCode="22",  
 versionName="2.2",  
 },  
  
 androidPermissions = {  
 "android.permission.INTERNET",  
 },   
}  

Does anyone have any ideas? I’m at a loss here.

Thanks! [import]uid: 114363 topic_id: 30716 reply_id: 330716[/import]

Hi there,

Looks fine to me, can you post the part of code that you are using to use to post to facebook? [import]uid: 62706 topic_id: 30716 reply_id: 123107[/import]

@CraftyDeano,

Sure… here’s the code. Note, that this does work for Android, but I cannot get results with iOS. Also to note… no error dialog boxes ever display, so it appears to the user that the message was posted.

Alert box with Facebook button:

 local alert = native.showAlert("Personal Best!",  
 "Congratulations! You beat your personal high score in this game!",  
 { "OK", "Brag on Facebook!" }, onComplete)  

My onComplete function

local function onComplete(event)  
 if event.action == "clicked" then  
 if event.index == 2 then   
 facebook.login(FACEBOOK\_APPID, fbListener, {"publish\_stream"})  
 end  
 end  
 return true  
end  

Finally, the fbListener function

local function fbListener(event)  
 local alert  
  
 if event.type == "session" then  
 if event.phase == "login" then  
 postMsg = {  
 message = "I just scored "..tostring(PLAYERDATA.SCORE)..   
 " in Spell Them Out!",  
 link = "http://www.gamesbycandlelight.com",  
 name = "Spell Them Out!",  
 caption = "Spell Them Out by Games By Candlelight",  
 description = "Spell words bla bla bla"  
 }  
 facebook.request("me/feed", "POST", postMsg)  
 else  
 alert = native.showAlert("Login Error",  
 "Error logging into Facebook",  
 { "OK" })   
 end  
  
 return  
 end  
  
 -- this handles the message received after a POST command  
 if event.type == "request" then   
 if event.isError then  
 alert = native.showAlert("Message Not Posted",  
 "Sorry, there was a problem posting to Facebook",  
 { "OK" })   
 else  
 alert = native.showAlert("Message Posted",  
 "High score posted to Facebook",  
 { "OK" })   
 end  
 end  
end  

Any help would be greatly appreciated.
–john [import]uid: 114363 topic_id: 30716 reply_id: 123132[/import]

Looking over your code I can’t see the issue.

To help debug, under line 14 of your fbListener function, add:

[lua]native.showAlert( “Facebook Response”, event.response, { “OK” } )[/lua]

Once it goes back to your app, it should print whatever response facebook gives.

[import]uid: 62706 topic_id: 30716 reply_id: 123136[/import]

That’s a good suggestion… I will do that.
I am also going to go through this module and check/rewrite a few things since it appears I can probably make this a bit more error-friendly to the user.

thanks! [import]uid: 114363 topic_id: 30716 reply_id: 123147[/import]

I have gone over my code 100 times, and I still cannot post to my Facebook wall using the iOS version of my app. On Android, it works perfectly. Is there something (anything!) that someone suggest I look at? Something maybe on the FB App page? (although I looked there quite a bit as well).

Basically, I can log into facebook, a blank fb window appears and then then my app appears to load again since it then shows the title page. Is that supposed to happen on iOS? It does not happen on Android… on Android, it just pops up a fb page and returns to the “game over” screen. Is this normal iOS behavior? My build.settings file does contain iUIApplicationExitsOnSuspend = false (as shown above), and I am using Storyboard and not removing the game over scene.so wouldn’t the app just return to where it was like it does with the Android version?

If I leave the iOS Bundle ID field on the FB config screen as blank, the first FB window will state that I am already verified, so it appears that I am actually logging into fb.

I tried trapping event.response so I can see it in an alert box, but since the app does not return to the game over screen, it does not display. (Again, it does display on Android).

Completely confused at this point. Anyone experience this and know what I am doing wrong or what I need to look out for?
[import]uid: 114363 topic_id: 30716 reply_id: 123349[/import]

If you are on iOS and have the FB app installed, Corona will call out to the FB app to auth you using URL schemas. The result of this is that your app is suspended temporarily, the fb app opens (the blank screen), it auths you and then calls your fb87298374238 (whatever your number is) URL to re-launch your suspended app, which should resume right back where you left it. This work like a charm. If this app is installed you must be logged in with it.

If you do not have the app installed, it calls the web version much like Android does. You will get a safari popup and you approve it and it returns to your app.

This is why you must have that exit on suspend value set to false or your app will exit, not stay in memory for relaunching. If you have exit on suspend true, you’re app will just relaunch itself from the beginning.

On your Facebook app page, your values have to be right:

After that, load up your code with print statements and see where you’re (not) getting too.

I don’t think you can use the wildcard bundle ID.
[import]uid: 19626 topic_id: 30716 reply_id: 123454[/import]

Hi there,

Looks fine to me, can you post the part of code that you are using to use to post to facebook? [import]uid: 62706 topic_id: 30716 reply_id: 123107[/import]

@CraftyDeano,

Sure… here’s the code. Note, that this does work for Android, but I cannot get results with iOS. Also to note… no error dialog boxes ever display, so it appears to the user that the message was posted.

Alert box with Facebook button:

 local alert = native.showAlert("Personal Best!",  
 "Congratulations! You beat your personal high score in this game!",  
 { "OK", "Brag on Facebook!" }, onComplete)  

My onComplete function

local function onComplete(event)  
 if event.action == "clicked" then  
 if event.index == 2 then   
 facebook.login(FACEBOOK\_APPID, fbListener, {"publish\_stream"})  
 end  
 end  
 return true  
end  

Finally, the fbListener function

local function fbListener(event)  
 local alert  
  
 if event.type == "session" then  
 if event.phase == "login" then  
 postMsg = {  
 message = "I just scored "..tostring(PLAYERDATA.SCORE)..   
 " in Spell Them Out!",  
 link = "http://www.gamesbycandlelight.com",  
 name = "Spell Them Out!",  
 caption = "Spell Them Out by Games By Candlelight",  
 description = "Spell words bla bla bla"  
 }  
 facebook.request("me/feed", "POST", postMsg)  
 else  
 alert = native.showAlert("Login Error",  
 "Error logging into Facebook",  
 { "OK" })   
 end  
  
 return  
 end  
  
 -- this handles the message received after a POST command  
 if event.type == "request" then   
 if event.isError then  
 alert = native.showAlert("Message Not Posted",  
 "Sorry, there was a problem posting to Facebook",  
 { "OK" })   
 else  
 alert = native.showAlert("Message Posted",  
 "High score posted to Facebook",  
 { "OK" })   
 end  
 end  
end  

Any help would be greatly appreciated.
–john [import]uid: 114363 topic_id: 30716 reply_id: 123132[/import]

Looking over your code I can’t see the issue.

To help debug, under line 14 of your fbListener function, add:

[lua]native.showAlert( “Facebook Response”, event.response, { “OK” } )[/lua]

Once it goes back to your app, it should print whatever response facebook gives.

[import]uid: 62706 topic_id: 30716 reply_id: 123136[/import]

That’s a good suggestion… I will do that.
I am also going to go through this module and check/rewrite a few things since it appears I can probably make this a bit more error-friendly to the user.

thanks! [import]uid: 114363 topic_id: 30716 reply_id: 123147[/import]

I have gone over my code 100 times, and I still cannot post to my Facebook wall using the iOS version of my app. On Android, it works perfectly. Is there something (anything!) that someone suggest I look at? Something maybe on the FB App page? (although I looked there quite a bit as well).

Basically, I can log into facebook, a blank fb window appears and then then my app appears to load again since it then shows the title page. Is that supposed to happen on iOS? It does not happen on Android… on Android, it just pops up a fb page and returns to the “game over” screen. Is this normal iOS behavior? My build.settings file does contain iUIApplicationExitsOnSuspend = false (as shown above), and I am using Storyboard and not removing the game over scene.so wouldn’t the app just return to where it was like it does with the Android version?

If I leave the iOS Bundle ID field on the FB config screen as blank, the first FB window will state that I am already verified, so it appears that I am actually logging into fb.

I tried trapping event.response so I can see it in an alert box, but since the app does not return to the game over screen, it does not display. (Again, it does display on Android).

Completely confused at this point. Anyone experience this and know what I am doing wrong or what I need to look out for?
[import]uid: 114363 topic_id: 30716 reply_id: 123349[/import]

If you are on iOS and have the FB app installed, Corona will call out to the FB app to auth you using URL schemas. The result of this is that your app is suspended temporarily, the fb app opens (the blank screen), it auths you and then calls your fb87298374238 (whatever your number is) URL to re-launch your suspended app, which should resume right back where you left it. This work like a charm. If this app is installed you must be logged in with it.

If you do not have the app installed, it calls the web version much like Android does. You will get a safari popup and you approve it and it returns to your app.

This is why you must have that exit on suspend value set to false or your app will exit, not stay in memory for relaunching. If you have exit on suspend true, you’re app will just relaunch itself from the beginning.

On your Facebook app page, your values have to be right:

After that, load up your code with print statements and see where you’re (not) getting too.

I don’t think you can use the wildcard bundle ID.
[import]uid: 19626 topic_id: 30716 reply_id: 123454[/import]