Trying to make the Facebook example project work!

yeah its the standard fb app. I was more interested in whether or not if you followed my steps (and created a brand new app id in the fb dev portal) and linked the sample app up to it whether it would work for you or not, rather than just using the pre-existing app id you guys already have setup in the fb dev portal.

Unless you have any better ideas on how to figure this out?

Ok so I have figured out what the problem was, and it is pretty stupid, but in my defence, it really wasn’t obvious. Basically it turns out that both devices were already signed into facebook (which i wasnt aware of, as i dont use fb on them). What was confusing me was that it just went straight to an error state. I grabbed an android device and tried on that, the difference was fb had never been used (by app or web signin) so i actually got a login prompt. Then if i logged in using the account registered on fb dev portal or the test account that gets created by default for each app on fb dev portal (Roles->Test Users) it works fine. Attempting to sign in with any other account will result in the error i was seeing (as was mentioned on other websites). So my issue was that i didnt know that both devices were signed in, on the one with the fb app i had to load the app, specifically logout and then the sample app worked ok. On the device without fb app, i had to goto the fb website specifically and then logout. As far as i can tell fb became logged in through use from another app on the device and i didnt know it would stay logged in permanently. 

Thanks for the insight, I too would like to add that for some reason my test device iPhone 5 didn’t work until I went to the settings on the phone, locate facebook, and sign on with my facebook account through the iPhone 5’s settings menu. Now I’m able to post messages to my wall via the app.

Logging off the facebook app with my username also helped. But what does that mean for someone whose already logged onto the facebook app, when I’m logged onto my facebook account and try to post it gives me the same error as cjorgens79

I am getting tester feedback along these lines as well. It seems to be difficult to pin the issues. Is there a simple troubleshooting flow we can point our users towards?

As far as i can tell, during the testing phase (when the app is unreleased), using normal fb accounts is difficult, they need to be added to your roles in the fb dev portal and accepted by those users. I found it is much easier to use the built in fb test accounts you can setup. In the fb dev portal -> roles -> test users you can insert a number of test user accounts (that run off a different fb server). Each of those accounts is a proper full fb account, you can set a pwd for each and login and use them like a normal account. You can link your test users as friends to other test users in your list. Basically attempting to use any account that isn’t a proper test account or a registered role in your fb dev portal while its in testing (prior to release) results in the sdk error 2. 

Hi bertolini.max

What ended up being the solution to your problem. Ive read through all those guides numerous times and i still just cant get it to work, im obviously missing something, i just cant figure out what. It doesnt help that the guides are a little out of date when compared to the developer facebook options you actually get presented with. 

Im also seeing “com.facebook.sdk error 2” in the console and also “app not setup the developers of this app have not set up this app properly for facebook login” when trying different things to make it work. I had no issues with my previous fb implementation, but that was about 15 months ago, just cant make it work with the new api. 

Cheers

Can you post a screen shot of your screen from developers.facebook.com?

Hi Rob,

I have taken the facebook sample app provided by corona as a basis to try and get integration working with no luck. Here is the details of what i have done.

  1. Create a provisioning profile specifically for this test app. In this case net.pocketplayground.coronasampleapp

  2. Create a new app in facebook developer portal

  3. Add an “iOS” platform to the app in fb dev portal.Set the bundle ID to net.pocketplayground.coronasampleapp to match my provisioning profile. Specify the store id of an existing app (i just referenced one of my other apps that i have published). Enable SSO. Enable Deep Linking.

  4. Left the other settings as default on the advanced and migrations page. (note: i wasnt sure about the “Native or Desktop app” setting, so i tried it both ways. 

Advanced page with Native or Desktop disabled

Advanced page with Native or Desktop enabled

Migrations page

  1. Set the required app id fields in the sample app

In build settings

            FacebookAppID = “645295625542769”,    – replace XXXXXXXXX with your facebook appId

            CFBundleURLTypes =

            {

                {

                    CFBundleURLSchemes =

                    {

                        “fb645295625542769”,    – replace XXXXXXXXX with your facebook appId

                    }

                }

            }

in main.lua

local appId  = “645295625542769”    – Add  your App ID here (also go into build.settings and replace XXXXXXXXX with your appId under CFBundleURLSchemes)

local apiKey = nil    – Not needed at this time

  1. Compile the app using my coronasampleapp provisioning profile

  2. Test the app using my iPad3 (iOS 5.1.1) which does not have the facebook app installed

Then when i click ok to return to the corona app, that just fails with this error (note the address bar)

  1. Test the app using my iPhone5 (iOS 6.0.2) which does have the facebook app installed

Same error, however pressing ok returns to the corona sample app correctly.

Note i am using the latest public release of Corona 2014.2189 (installed the (2189a) build on the mac).  

So thats everything i did (based on the instructions in the links you provided). I have also attached the facebook sample app with the changes i made to the app id’s for your reference. 

On a related note, a couple of doco and sample issues i noted.

A note re the instructions at http://docs.coronalabs.com/guide/social/setupFacebook/index.html. It says " iPhone App Store ID  and/or  iPad App Store ID  is required for Facebook  Single Sign-On. See the Build Settings (iOS) section below for further details", that Build Settings iOS link goes nowhere and there is no “Build Settings (iOS)” section below. 

Another note re the facebook sample app that comes with corona, in main.lia where you get people to specify their app id 

local appId  = XXXXXXXXX     – Add  your App ID here (also go into build.settings and replace XXXXXXXXX with your appId under CFBundleURLSchemes)

It should really be local appId = “XXXXXXXXX”  <-- note the quotes, as the facebook.login function requires a string, not a number. The original line indicates that it is a number, as you tell people to just replace the XXXXXXXX part with their id. 

Please advise as I am complete stuck at the moment. 

Cheers

Craig

In step 6 you marked out some information.  You need to use a provisioning profile that uses a Bundle ID that matches what you told Facebook you are using.  That is likely the issue.

Rob

Thats my developer ID that i blacked out. So your saying i need to put the developer id in front of the app id? eg XXXXXXX.net.pocketplayground.coronasampleapp? I did try that previously but i will give it another go with this sample app. 

I guess I mis-read that. It didn’t look like the profile you had selected in corona was the same as the one you created in the provisioning portal.  Looking at one of my apps that I know works, you should turn on a couple of things that are off:

Native or Desktop.app should be on.

Embedded browser oAuth Login should be on.

Try those…

Rob

I have turned those two settings on but its still reporting the same error.

Note: I have only tried on my iPhone5 so far which has the facebook application installed, i will try the iPad with the web sign in later once i get home. 

Have now tried the iPad with the web sign in and same error still with that.

Can you post the console.log from your device?

Thanks

Rob

Hi Rob,

Attached is the console app results from attempting to run the app and login to fb. 

Regards

Craig

This may be of some use helping diagnose this:

http://stackoverflow.com/questions/14159965/com-facebook-sdk-error-2-on-ios

Yeah i have already read that post when originally trying to diagnose the issue. To address their points, 

  • BundleIdentifier and BundleURLName - have confirmed these match
  • The app is still in Sandbox mode - not sure what this refers to exactly, i presume its something from the old facebook developer portal UI. Perhaps it corrosponds to the “Status and Review” page setting about makign it available to the public whcih i currently have set to no, as its not a released app yet.
  • The app does not appear at all in the Facebook Settings (device’s settings -> Facebook -> Allow These Apps To Use Your Account), i dont have this section at all in fact. I would imagine this would only reply to devices with the facebook app installed, however problems occurs with both the fb app and web login.
  • Apparently phonegap had some permissions error that they had to fix, assuming corona doesnt have this problem.

Have you tried actually compiling and running the sample app i attached? Could you create a new App in the FB dev portal and setup the sample app i provided to use it and see if you get the same problem as i do or not?

Thanks

The sample you sent looks like the standard FB app with your AppID.  Is there anything different?

yeah its the standard fb app. I was more interested in whether or not if you followed my steps (and created a brand new app id in the fb dev portal) and linked the sample app up to it whether it would work for you or not, rather than just using the pre-existing app id you guys already have setup in the fb dev portal.

Unless you have any better ideas on how to figure this out?

Ok so I have figured out what the problem was, and it is pretty stupid, but in my defence, it really wasn’t obvious. Basically it turns out that both devices were already signed into facebook (which i wasnt aware of, as i dont use fb on them). What was confusing me was that it just went straight to an error state. I grabbed an android device and tried on that, the difference was fb had never been used (by app or web signin) so i actually got a login prompt. Then if i logged in using the account registered on fb dev portal or the test account that gets created by default for each app on fb dev portal (Roles->Test Users) it works fine. Attempting to sign in with any other account will result in the error i was seeing (as was mentioned on other websites). So my issue was that i didnt know that both devices were signed in, on the one with the fb app i had to load the app, specifically logout and then the sample app worked ok. On the device without fb app, i had to goto the fb website specifically and then logout. As far as i can tell fb became logged in through use from another app on the device and i didnt know it would stay logged in permanently.