Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'FBSession: No AppID provided

I just updated my app with the new Facebook 3.0 SDK for iOS. Prior to this I was using the SDK that utilized FBSessionDelegate and FBRequestDelegate. In that SDK, we had to place this code in the applicationDidFinishLaunching:

 facebook = [[Facebook alloc] initWithAppId:FB_APP_ID andDelegate:self];

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] 
    && [defaults objectForKey:@"FBExpirationDateKey"]) {
    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
} 

However now with the new 3.0 SDK, I'm told that all we have to do is import the framework, and resource bundles, then "add id named FacebookAppID to the bundle *.plist" So I've done this, but when I call any code with FBSession in it, I'm getting this error:

 'FBSession: No AppID provided; either pass an AppID to init, or add a string valued key with the appropriate id named FacebookAppID to the bundle *.plist'

What could I be doing wrong?

like image 693
Kwame Avatar asked Sep 17 '12 16:09

Kwame


4 Answers

It is sufficient to have the "FacebookAppID" entry in the plist file.

However I had the same problem after copying the "FacebookAppID" string from the documentation web site into the plist file in Xcode. After removing the "FacebookAppID" entry from the plist file and reentering it by actually typing it, it worked!

So when copy/pasting the string "FacebookAppID" from the HTML file to the plist file either some invisible markup was also copied or the character encoding got messed up.

like image 127
Volker Voecking Avatar answered Nov 13 '22 13:11

Volker Voecking


Just for heads up. I had this issue today and eventually I simply noticed that I simply placed the entries in the wrong .plist file. If you filter your project files (down to the left) type in .plist and you might see two files. one is the tests' and the other is the one you actually need to set up. Good luck!

like image 33
Jackson Avatar answered Nov 13 '22 11:11

Jackson


I'm still not sure why this is happening, but my workaround was to check if the FBSession object has an APP_ID and if not, then to set it manually:

if (![FBSession defaultAppID]) {
    [FBSession setDefaultAppID:FB_APP_ID];
}

Hope this helps someone!

like image 5
Kwame Avatar answered Nov 13 '22 13:11

Kwame


In my case i stupidly typed FacebookAppId with a lower case 'd'. Just putting it out in case someone had the same problem.

like image 5
Henry Avatar answered Nov 13 '22 12:11

Henry