Facing the following problem: need to perform Facebook login in IOS 7. The thing goes right on the emulator but when running it on device with native app installed, the session give not permission to perform the login.
Using the code to create session:
The checarLogin method works like:
I have googled to find it and figured out that the device settings that control the permissions of Facebook app works differently in the two cases:
Emulator give the permission with no issues:
The following image was took from emulator too, but only to illustrate the way the device works by default:
So the question is: there is other way to handle the login when running in a real device with native Facebook app installed and make it accept the permissions without the need to change the iphone settings?
This is what I use in my apps, you have to allow the login UI.
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI completionHandler:(FBSessionStateHandler)handler {
// We pass this permissions array into our request.
// I only request email, but there are many more options.
//
NSArray *permissions = @[@"email", @"basic_info"];
return [FBSession
openActiveSessionWithReadPermissions:permissions
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
if (handler)
handler(session, state, error);
}];
}
And that's how you use it
[self openSessionWithAllowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (!error && status == FBSessionStateOpen) {
NSString *token = session.accessTokenData.accessToken;
// You're logged in!
} else {
// Something wrong happened
}
}];
I faced a similar problem, and this is what worked for me:
https://stackoverflow.com/a/12069251/2407717
A colleague changed some of our project settings, including the Bundle Identifier , so it wasn't matching the iOS Bundle ID on Facebook anymore.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.