How to authorize a user through DIALOG using the new iOS Facebook Connect API?

I understand - http://developers.facebook.com/docs/guides/mobile/#ios - seems really useful, but my application does not support multitasking, so this cross safari method will not work for me.

Is there any short example somewhere (or can someone copy here) the authentication process through FBDialogs (using this so-called β€œnew” API)? I just know this SDK, so please as much as possible.

+6
iphone facebook
source share
2 answers

Struggling to figure this out for hours ...

Here is the fb app authentication bypass solution | background-safari, and this is just a change to Facebook.m:

[self authorizeWithFBAppAuth:YES safariAuth:YES] 

to

 [self authorizeWithFBAppAuth:NO safariAuth:NO] 

in the method:

 - (void)authorize:(NSArray *)permissions delegate:(id<FBSessionDelegate>)delegate 

.

Check it with the sample code without changing anything else (of course, install kAppId on yours)

I was completely crazy why on earth FB is not documenting this ...

Hope this helps,

Greetings

+10
source share

All the magic is in

 - (void)authorize:(NSArray *)permissions delegate:(id<FBSessionDelegate>)delegate 

which call [self authorizeWithFBAppAuth:YES safariAuth:YES] :

  • FBAppAuth:YES will attempt to authenticate using the Facebook application if installed
  • safariAuth:YES will attempt to authenticate with Safari if the device supports multitasking

So you want [self authorizeWithFBAppAuth:NO safariAuth:NO]

If you want to leave the unmodified Facebook SDK, you can simply β€œexpose” their private api:

 @interface Facebook (Private) - (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth safariAuth:(BOOL)trySafariAuth; @end 

And then continue if with a category:

 @interface Facebook (MyApp) - (void)myAuthorize:(id<FBSessionDelegate>)delegate; @end @implementation Facebook (MyApp) - (void)myAuthorize:(id<FBSessionDelegate>)delegate { _permissions = [[NSArray arrayWithObjects:@"email", *(whatever you need)*, nil] retain]; _sessionDelegate = delegate; [self authorizeWithFBAppAuth:NO safariAuth:NO]; // force in app auth } @end 

Then use it almost normally:

  Facebook *facebook = [[Facebook alloc] initWithAppId:MY_APP_FB_ID]; [facebook myAuthorize:self]; 

What they didn’t implement the popular request, there is even pull requests using solutions ...

+8
source share

All Articles