FaceBook API, application login

I followed this guide and I have successfully created an application with integration with Facebook.

What is the problem?

When the user must log in, the application closes in the browser (or in the Facebook application, if installed)

How to keep authenticity completely in the application?

+4
source share
2 answers

The oAuth login point is that this does not happen in your application. It uses fast switching applications for authentication in a reliable environment (Safari or Facebook application).

However, you can change Facebook.m to authenticate in your application, but your credentials will not be remembered. You can see that if your iOS device does not support multitasking, a login dialog appears.

Excerpt from Facebook.m (near line 160):

if ([device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported]) { if (tryFBAppAuth) { NSString *scheme = kFBAppAuthURLScheme; if (_localAppId) { scheme = [scheme stringByAppendingString:@"2"]; } NSString *urlPrefix = [NSString stringWithFormat:@"%@://%@", scheme, kFBAppAuthURLPath]; NSString *fbAppUrl = [FBRequest serializeURL:urlPrefix params:params]; didOpenOtherApp = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fbAppUrl]]; } if (trySafariAuth && !didOpenOtherApp) { NSString *nextUrl = [self getOwnBaseUrl]; [params setValue:nextUrl forKey:@"redirect_uri"]; NSString *fbAppUrl = [FBRequest serializeURL:loginDialogURL params:params]; didOpenOtherApp = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fbAppUrl]]; } } // If single sign-on failed, open an inline login dialog. This will require the user to // enter his or her credentials if (!didOpenOtherApp) { [_loginDialog release]; _loginDialog = [[FBLoginDialog alloc] initWithURL:loginDialogURL loginParams:params delegate:self]; [_loginDialog show]; } 

If you delete the first conditional code and it contains the code and set didOpenOtherApp to NO, you can get the behavior you are looking for.

+3
source

To disable this behavior, change Facebook.m line 275 and set both options to NO.

 - (void)authorize:(NSArray *)permissions { self.permissions = permissions; // with both options NO, authorization always happens in-app [self authorizeWithFBAppAuth:NO safariAuth:NO]; } 
+2
source

All Articles