I am integrating facebook login in my application.
When I request the user for permissions the default UI get presented to him in order to accept the permissions, and then when he clicks on "okay" it will return from the ui to my app in order to continue.
However the default Permission UI remains open in the browser (if I quit the application and open the browser I still see the permission UI that was presented to him earlier. Is there a way I can close the page in the browser after the user gives permission?
Hope I was clear
This is the code I am using:
This method will show the user the facebook login page in order to get his permission
-(BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"user_location",
@"user_birthday",
nil];
return [FBSession openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self HandleLogin];
}];
}
Then if login and permission successful
- (void)HandleLogin {
if (FBSession.activeSession.isOpen) {
[FBRequestConnection
startForMeWithCompletionHandler:^(FBRequestConnection *connection,
id<FBGraphUser> user,
NSError *error) {
//DO SOMETHING WITH THE USER INFO
}];
}
}
The code to process the return from the Facebook app
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// attempt to extract a token from the url
return [FBSession.activeSession handleOpenURL:url];
}
Facebook SDK is pretty problematic, I'd say. Personally, I had displeasure to integrate FB picture sharing into several projects (while their developers released several new SDKs). I don't know, why browser redirection becomes popular, honestly, I don't like it. Generally, I don't think that it is possible to somehow clear this unwanted content from your browser without opening new url from application since it is not a solution. What I'd suggest is to force FB SDK to use WebView. In last version I used, this is set when you create new session with custom behavior. Code should be like this or pretty similar:
[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView
completionHandler:^(FBSession *session, FBSessionState status, NSError *error)handler]