Problems with iOS for iOS Facebook, etc.

I have included facebook ios sdk in my application. When I first did this, it was connected to my ViewController class ONLY. So it worked just like a demo. He also worked. I was able to post everything, etc. My app delegate has the correct url file to connect in it etc.

The problem arose when I changed my application to have a different main screen, and on the last screen there is information about connecting to facebook. So now my App Delegate has a function:

-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
   SocialView *socialView = [[SocialView alloc] init];
   return [[socialView facebook] handleOpenURL:url];
}

Because of this change, my variable is facebookalways nullon return from login and didLogin is never called. I assume this is because every time it returns a view, it is recreated, and also facebook var is replaced.

What is the solution? Thanks for any help ...

-d

Edit: It is worth noting that if I had only one view:

-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
   return [[viewController facebook] handleOpenURL:url];
}

works great.

+3
source share
1 answer
David, you're right. The solution you show allocates an alternate view controller every time authentication is complete and the application returns from facebook-connect. Thus, nothing can be saved.

Here's what you should do: suppose your viewcontroller that handles facebook-connect is called facebookViewController, then you need the code:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {

return [[viewController.facebookViewController facebook] handleOpenURL:url]; 
}

Try it and let me know if you have it :) Good luck.

+1
source

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


All Articles