Facebook ios-sdk api, delegates do not work, fbDidLogin is not called

I have a problem with the latest iOS sdk. I successfully log in and the application returns, but delegation methods like fbDidLogin etc. are not called.

If you tried everything in one delegate file without any controllers and got it working. But if I have multiple controllers, it no longer works /

I use my own written FacebookFetchter class to work with Facebook.

  //FacebookFetchter.h #import Foundation/Foundation.h> #import "FBConnect.h" @interface FacebookFetchter : NSObject <FBDialogDelegate,FBSessionDelegate,FBRequestDelegate> { Facebook *facebook; FacebookFetchter *facebookFetcher; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (retain) Facebook *facebook; @property (retain) FacebookFetchter *facebookFetcher; @end 


  // FacebookFetchter.m #import "FacebookFetchter.h" @implementation FacebookFetchter @synthesize facebookFetcher,facebook; -(void)login{ NSLog(@"facebook login..."); facebook = [[Facebook alloc] initWithAppId:@"..."]; //took the id out NSArray *permissions = [[NSArray arrayWithObjects: @"read_stream", @"offline_access", @"user_photos", @"user_photo_video_tags" , @"friends_photo_video_tags", @"friends_photos",@"friends_about_me",@"user_about_me",@"manage_friendlists",@"read_friendlists",@"user_birthday",@"friends_birthday", nil] retain]; [facebook authorize:permissions delegate:self]; } ... -(void)fbDidLogin { NSLog(@"Erfolgreich eingeloggt...."); } ... @end 

In my case, I implemented this, and I also configured plist using the fbapp_id URL scheme

 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { NSLog(@"AppDelegate handleOpenURL"); return [[[settings facebookFetcher] facebookFetcher] handleOpenURL:url]; } 

there the settings are my view controller:

 //settings.h @interface Settings : UIViewController { FacebookFetchter *facebookFetcher; //Facebook *facebook; } @property (retain) FacebookFetchter *facebookFetcher; - (IBAction)sync; @end //settings.m @synthesize facebookFetcher; //within this action the facebook login is called - (IBAction)sync{ NSLog(@"sync..."); facebookFetcher = [[FacebookFetchter alloc] init]; [facebookFetcher login]; } 

Any suggestions

Thanks!

+4
source share
3 answers

I had this problem and I believe that I have found my solution. When you create the application on facebook, you have to edit the settings of your application in order to enable the native ios application. The ios package ID you select must EXACTLY match your package ID in the application you are creating. Facebook states that they verify this before authorizing your application. It’s funny if you remove the facebook application from the device and then try to authenticate it, it uses a web browser and, apparently, completely blocks this β€œsecurity”. Facebook did not send an error message, so it was very interesting to track. I decided that I would drop this answer there to save some future developers. Hope this helps.

+3
source

I ran into the same problem. For me, this was decided by unchecking the "Application does not work in the background" checkbox in Info plist.

+1
source

I had the same problem. I did not set permissions to access facebook. I wrote an extra line of code

NSArray *permissions = [[NSArray arrayWithObjects:@"read_stream",@"offline_access","publish_stream", nil] retain];

Works great.

+1
source

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


All Articles