"FBSession: no application

I just updated my app with the new Facebook 3.0 SDK for iOS. Before that, I used the SDK, which used FBSessionDelegate and FBRequestDelegate. In this SDK, we had to put this code in 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, they told me that all we need to do is import the framework and resource packs, and then “add the identifier with the name FacebookAppID to the * .plist package”. So, I did this, but when I call any code with FBSession in it, I get 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 can i do wrong?

+6
source share
7 answers

@Kwame I encountered the same problem, the session object does not have an application identifier. To do this, you can add a key to info.plist with the name FacebookAppID and set the corresponding value with the application identifier provided in your ios application using facebook. or if, if you have already done this, you can set the application identifier programmatically by setting the appropriate values ​​in the method - (id)initWithAppID:(NSString*)appID permissions:(NSArray*)permissions urlSchemeSuffix:(NSString*)urlSchemeSuffix tokenCacheStrategy:(FBSessionTokenCachingStrategy*)tokenCachingStrategy; . Also, please cross over the application id value in info.plist. Hope this helps.

+3
source

It is enough to have a FacebookAppID entry in the plist file.

However, I had the same problem after copying the line “FacebookAppID” from the documentation website to the plist file in Xcode. After deleting the FacebookAppID entry from the plist file and re-entering it , actually typing it , it worked!

So, when copying / pasting the line "FacebookAppID" from the HTML file to the plist file, either some invisible markup was also copied, or the character encoding was corrupted.

+13
source

Just for the head. I had this problem today and in the end I just noticed that I just placed the entries in the wrong .plist file. If you are filtering project files (on the left), enter .plist and you can see two files. one is tests, and the other is the one you really need to configure. Good luck

+6
source

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

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

Hope this helps someone!

+5
source

In my case, I stupidly typed FacebookAppId with the lowercase 'd'. Just put it in case someone has the same problem.

+5
source

Another possible mistake you can make here is to use a quick search to search for "plist" and not notice that you are adding the application identifier to the wrong plist file. If you have enabled a framework such as the Google Maps SDK, it has its own plist file.

+2
source

in addition to the previous answers: even if you notice that you added the FacebookAppID to the file the wrong * .plist and you still have the same error, check again . You may have replaced it with another incorrect * .plist

-1
source

Source: https://habr.com/ru/post/925596/


All Articles