Facebook frustrations

I recall being able to log out of the native FB app back when I was doing Phone Gap apps, but in looking for example iOS apps, I have found that the apps that are doing what I’m trying to do are using a popup window to ask for the FB login credentials and not using the native app.  So, yes, not doing it with the native app is fine as long as I can not automatically launch the native FB app and use a browser dialog even if the native app is installed.

An example of an app that is doing exactly what I am doing is: https://itunes.apple.com/us/app/picpic-social/id611055461?mt=8&uo=4

And here’s how phonegap does it.  https://github.com/phonegap/phonegap-facebook-plugin

They are using the FB Javascript SDK

https://github.com/phonegap/phonegap-facebook-plugin/blob/master/www/facebook-js-sdk.js

[lua]

/**

* Logout the user in the background.

*

* Just like logging in is tied to facebook.com, so is logging out – and

* this call logs the user out of both Facebook and your site. This is a

* simple call:

*

* FB.logout(function(response) {

* // user is now logged out

* });

*

* NOTE: You can only log out a user that is connected to your site.

*

* @access public

* @param cb {Function} The callback function.

*/

  logout: function(cb) {

    FB.ui({ method: ‘auth.logout’, display: ‘hidden’ }, cb);

  }

[/lua]

which calls logout in https://github.com/phonegap/phonegap-facebook-plugin/blob/master/src/ios/FacebookConnectPlugin.m

[lua]

  • (void) logout:(CDVInvokedUrlCommand*)command

{

    if (!FBSession.activeSession.isOpen) {

        return;

    }

    

    // Close the session and clear the cache

    [FBSession.activeSession closeAndClearTokenInformation];

    

    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];

    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];

}

[/lua]

I hope people are not forgetting about the sample code that comes with Corona.   I copied a couple snippets from the sample code and got an image, along with episode, level, and score, posted to Facebook pretty easily from Android.

Question about iOS, though.   It appears that on the Facebook Dev portal, I have to specify my App Store ID to get this working.   Well, my game isn’t in the app store yet, because I don’t have Facebook posting working for iOS.

Seems like a catch-22 to me.   Do I have to release a first version to the app store without the Facebook stuff, then a subsequent release with it?    

@davemikesell, You don’t need to release your app on the App Store to get an iOS app store id. You get the id just by setting up the app in the iOS provisioning portal followed by in iTunes Connect. Hope this helps. - Andrew

I’ve done that.   Noticed from the sample app that my build.settings didn’t include the FB app ID (does that need to be prefixed by fb?), so I added that, but still not working.  The listener is not getting called after facebook.login() (this is working on Android for me).   

Also, on the Facebook portal, should the bundle ID include the prefix, or just the com.company.appname?

Finally, I’m using a developer provisioning profile.   Maybe I need to create and use a distribution profile.

Success.   I followed the instructions at the link below and can now post to FB from iOS.    Holy crap, I may be able to release this thing :slight_smile:

http://www.coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Just a clarification:  The facebook.* API calls needs an AppID provided by Facebook when you create your app on their developer portal (http://developers.facebook.com).  

To setup an iOS native app, they want the iTunes connect App ID Number so they can fetch information about your app to show in their displays.  This is really not needed during testing, so you can use the iTunes App ID number (not your app bundle ID)  of any live app, just  make sure to update it to yours after your app pushes live.

I think I’m set there, Rob.  I’m using the iTunes Connect app id.

Just got Twitter working, too, using the sample app code.    

There has yet to be created a device that can measure the awesomeness of Corona.

:wub:

Any luck checking out that other app and/or seeing how the Phonegap plugin works to allow for a dialog to login and still manages to logout?

Dear Rob,

Thanks for making time to sort out these issues. My facebook login worked previously (~2 months ago during my initial test), but now, it doesn’t. I am testing it back on the sample app, ‘facebook’. It works on an Android device (with a Facebook app installed), but not on Xcode Simulator (iOS 6.1).

What I have done. I setup my facebook based on “http://docs.coronalabs.com/guide/social/setupFacebook/index.html#iosbuild”. I inserted the “Bundle ID” (e.g. com.myWeb.app),   the “iPhone App Store ID” at " 409807569" .  “Facebook Login” and “Deep Linking” are enabled.

My problem is that, everytime I try to facebook-login, safari appears for a few seconds , then it goes back to the app with a failed-login. If i select “Show Dialog”, a native window appears and ask for Facebook-login credentials. If I enter facebook in there, i am able to post something to my facebook-wall. Login on “Show Dialog” will not have any effect on the corona API Facebook-login (meaning if I am able to login on “Show Dialog”, I am still not logged in on the corona facebook-API).

The error shown is as below (taken from console) :

9/29/13 8:15:44.925 PM Facebook4[7752]: Facebook (original) Listener events: 9/29/13 8:15:44.925 PM Facebook4[7752]: type(session) 9/29/13 8:15:44.926 PM Facebook4[7752]: name(fbconnect) 9/29/13 8:15:44.926 PM Facebook4[7752]: phase(loginFailed) 9/29/13 8:15:44.926 PM Facebook4[7752]: isError(true) 9/29/13 8:15:44.927 PM Facebook4[7752]: response(The operation couldn’t be completed. (com.facebook.sdk error 2.)) 9/29/13 8:15:44.927 PM Facebook4[7752]: event.name fbconnect 9/29/13 8:15:44.927 PM Facebook4[7752]: event.type: session 9/29/13 8:15:44.928 PM Facebook4[7752]: isError: true 9/29/13 8:15:44.928 PM Facebook4[7752]: didComplete: nil 9/29/13 8:15:44.928 PM Facebook4[7752]: Session Status: loginFailed

build-settings (last 2-digits is masked with xx) :

settings = { orientation = { default = "portrait", supported = { "portrait" } }, android = { usesPermissions = { "android.permission.INTERNET", }, }, iphone = { plist = { CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-72.png", "Icon-72@2x.png", }, UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work FacebookAppID = "3455772522396xx", -- replace XXXXXXXXX with your facebook appId CFBundleURLTypes = { { CFBundleURLSchemes = { "fb3455772522396xx", -- replace XXXXXXXXX with your facebook appId } } } } } }

I did a quick Google on “com.facebook.sdk error 2” to see what thats about.   A couple of common things came up.  Are you in “sandbox mode”?  If so, turn it off.  Make sure your bundle ID is the same (I think it’s case sensitive).  Others reported problems with the simulator, have you tried it on device yet?   There is also the realistic issue that it is a real timeout from Facebook too.

Others report interaction problems with the device’s build in facebook support, but I don’t believe that’s a real issue.  The Simulator is really pokey and I’d like to know how this behaves on device instead of in the Xcode simulator.

Dear Rob,

Spot On! It worked on my device, iOS7-beta iPad (with facebook app installed). Not sure why it did not work on my Xcode simulator (still on iOS6.1). 

I will further test it out by un-installing the facebook app on the iPad to see how it performs.

I hope people are not forgetting about the sample code that comes with Corona.   I copied a couple snippets from the sample code and got an image, along with episode, level, and score, posted to Facebook pretty easily from Android.

Question about iOS, though.   It appears that on the Facebook Dev portal, I have to specify my App Store ID to get this working.   Well, my game isn’t in the app store yet, because I don’t have Facebook posting working for iOS.

Seems like a catch-22 to me.   Do I have to release a first version to the app store without the Facebook stuff, then a subsequent release with it?    

@davemikesell, You don’t need to release your app on the App Store to get an iOS app store id. You get the id just by setting up the app in the iOS provisioning portal followed by in iTunes Connect. Hope this helps. - Andrew

I’ve done that.   Noticed from the sample app that my build.settings didn’t include the FB app ID (does that need to be prefixed by fb?), so I added that, but still not working.  The listener is not getting called after facebook.login() (this is working on Android for me).   

Also, on the Facebook portal, should the bundle ID include the prefix, or just the com.company.appname?

Finally, I’m using a developer provisioning profile.   Maybe I need to create and use a distribution profile.

Success.   I followed the instructions at the link below and can now post to FB from iOS.    Holy crap, I may be able to release this thing :slight_smile:

http://www.coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Just a clarification:  The facebook.* API calls needs an AppID provided by Facebook when you create your app on their developer portal (http://developers.facebook.com).  

To setup an iOS native app, they want the iTunes connect App ID Number so they can fetch information about your app to show in their displays.  This is really not needed during testing, so you can use the iTunes App ID number (not your app bundle ID)  of any live app, just  make sure to update it to yours after your app pushes live.

I think I’m set there, Rob.  I’m using the iTunes Connect app id.

Just got Twitter working, too, using the sample app code.    

There has yet to be created a device that can measure the awesomeness of Corona.

:wub:

Dear Rob,

Thanks for making time to sort out these issues. My facebook login worked previously (~2 months ago during my initial test), but now, it doesn’t. I am testing it back on the sample app, ‘facebook’. It works on an Android device (with a Facebook app installed), but not on Xcode Simulator (iOS 6.1).

What I have done. I setup my facebook based on “http://docs.coronalabs.com/guide/social/setupFacebook/index.html#iosbuild”. I inserted the “Bundle ID” (e.g. com.myWeb.app),   the “iPhone App Store ID” at " 409807569" .  “Facebook Login” and “Deep Linking” are enabled.

My problem is that, everytime I try to facebook-login, safari appears for a few seconds , then it goes back to the app with a failed-login. If i select “Show Dialog”, a native window appears and ask for Facebook-login credentials. If I enter facebook in there, i am able to post something to my facebook-wall. Login on “Show Dialog” will not have any effect on the corona API Facebook-login (meaning if I am able to login on “Show Dialog”, I am still not logged in on the corona facebook-API).

The error shown is as below (taken from console) :

9/29/13 8:15:44.925 PM Facebook4[7752]: Facebook (original) Listener events: 9/29/13 8:15:44.925 PM Facebook4[7752]: type(session) 9/29/13 8:15:44.926 PM Facebook4[7752]: name(fbconnect) 9/29/13 8:15:44.926 PM Facebook4[7752]: phase(loginFailed) 9/29/13 8:15:44.926 PM Facebook4[7752]: isError(true) 9/29/13 8:15:44.927 PM Facebook4[7752]: response(The operation couldn’t be completed. (com.facebook.sdk error 2.)) 9/29/13 8:15:44.927 PM Facebook4[7752]: event.name fbconnect 9/29/13 8:15:44.927 PM Facebook4[7752]: event.type: session 9/29/13 8:15:44.928 PM Facebook4[7752]: isError: true 9/29/13 8:15:44.928 PM Facebook4[7752]: didComplete: nil 9/29/13 8:15:44.928 PM Facebook4[7752]: Session Status: loginFailed

build-settings (last 2-digits is masked with xx) :

settings = { orientation = { default = "portrait", supported = { "portrait" } }, android = { usesPermissions = { "android.permission.INTERNET", }, }, iphone = { plist = { CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-72.png", "Icon-72@2x.png", }, UIApplicationExitsOnSuspend = false, -- must be false for single sign-on to work FacebookAppID = "3455772522396xx", -- replace XXXXXXXXX with your facebook appId CFBundleURLTypes = { { CFBundleURLSchemes = { "fb3455772522396xx", -- replace XXXXXXXXX with your facebook appId } } } } } }

I did a quick Google on “com.facebook.sdk error 2” to see what thats about.   A couple of common things came up.  Are you in “sandbox mode”?  If so, turn it off.  Make sure your bundle ID is the same (I think it’s case sensitive).  Others reported problems with the simulator, have you tried it on device yet?   There is also the realistic issue that it is a real timeout from Facebook too.

Others report interaction problems with the device’s build in facebook support, but I don’t believe that’s a real issue.  The Simulator is really pokey and I’d like to know how this behaves on device instead of in the Xcode simulator.