'FBSession: No AppID provided
Asked Answered
E

8

6

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?

Earthshaker answered 17/9, 2012 at 16:34 Comment(0)
P
3

@Kwame I faced the same problem , you session object is missing the App id . For this you can add an key in the info.plist named FacebookAppID and set the appropriate value with the app id provided to your ios app by facebook. or if in case you have already done this you can set the app id programmatically by setting the appropriate values in the - (id)initWithAppID:(NSString*)appID permissions:(NSArray*)permissions urlSchemeSuffix:(NSString*)urlSchemeSuffix tokenCacheStrategy:(FBSessionTokenCachingStrategy*)tokenCachingStrategy; method . Also please cross check the value of app id in info.plist. Hope this helps.

Percale answered 20/9, 2012 at 15:15 Comment(1)
Thanks. It's just that the Facebook iOS SDK docs make it seem like all you have to do is set the FacebookAppID info.plist. They don't bother to tell all these different ways of doing it.Earthshaker
S
13

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.

Scabious answered 4/2, 2013 at 14:36 Comment(2)
Huh... crazy. this took me ages to figure out, but this answer actually fixed the issue. Thanks!Hurtless
Absolutely crazy, this works. I guess it has something to do with how plist files are being cached and updated.Journalese
H
6

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!

Horten answered 18/5, 2014 at 20:27 Comment(0)
E
5

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!

Earthshaker answered 17/9, 2012 at 19:35 Comment(1)
it is deprecated in New facebook SDK. do you have any idea for new method?Bearded
O
5

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

Osrock answered 14/11, 2013 at 16:5 Comment(0)
P
3

@Kwame I faced the same problem , you session object is missing the App id . For this you can add an key in the info.plist named FacebookAppID and set the appropriate value with the app id provided to your ios app by facebook. or if in case you have already done this you can set the app id programmatically by setting the appropriate values in the - (id)initWithAppID:(NSString*)appID permissions:(NSArray*)permissions urlSchemeSuffix:(NSString*)urlSchemeSuffix tokenCacheStrategy:(FBSessionTokenCachingStrategy*)tokenCachingStrategy; method . Also please cross check the value of app id in info.plist. Hope this helps.

Percale answered 20/9, 2012 at 15:15 Comment(1)
Thanks. It's just that the Facebook iOS SDK docs make it seem like all you have to do is set the FacebookAppID info.plist. They don't bother to tell all these different ways of doing it.Earthshaker
F
2

Another possible mistake you can make here is to use the quick search to search for "plist" and not notice that you're adding the App ID to the wrong plist file. If you've included a framework like the Google Maps SDK it has its own plist file.

Frictional answered 31/10, 2013 at 17:6 Comment(0)
I
0

AppDelegate.swift

import FBSDKCoreKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    FBSDKSettings.setAppID("FacebookAppID")

    return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options) {
    return true
}

return true
}
Inductee answered 10/9, 2018 at 7:18 Comment(0)
S
-1

just in addition to previous answers: even if you noticed that you added FacebookAppID into a wrong *.plist file and you still have the same error, check again. Probably, you replaced it into another wrong *.plist

Sholom answered 8/7, 2014 at 16:54 Comment(4)
this belongs in a comment on the previous answerJerlenejermain
@Félix yes, but I meant that its possible to make mistake twice, especially if you have few attached libraries with their own plists. So just need to be very attentive, its quite common and quite stupid bug.Sholom
yep. So put it in a comment :) comments exists exactly for those precisions and "you need to be attentive" hints. other people can then vote for your comment if they find it useful, there is even a badge for very good comments :)Jerlenejermain
@Félix ok, thanks :) but i have no rights to comment yetSholom

© 2022 - 2024 — McMap. All rights reserved.