1

I need to install my app on a totem in an exhibition stand. The application flow is:

1) User takes a photo

2) User taps on a FBLoginView that open the Facebook app. The user makes the login and the Facebook app automatically returns to my app.

FBLoginView *loginView = [[FBLoginView alloc] initWithReadPermissions:
                          @[@"public_profile", @"email", @"user_friends"]];

// Align the button in the center horizontally
loginView.delegate = self;

loginView.frame = CGRectOffset(loginView.frame, (self.view.center.x - (loginView.frame.size.width / 2)), 5);
[self.view addSubview:loginView];

3) User taps on UIButton for post the photo and the Facebook app is opened again. The code for sharing is the following

NSArray* images = @[
                    @{@"url": [UIImage imageNamed:@"zoom_out_(25x25)"], @"user_generated" : @"true" }
                    ];

id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:@"https://example.com/cooking-app/meal/Lamb-Vindaloo.html" forKey:@"meal"];
[action setObject:images forKey:@"image"];

[FBDialogs presentShareDialogWithOpenGraphAction:action
                                      actionType:@"fbsdktoolkit:cook"
                             previewPropertyName:@"meal"
                                         handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
                                             if(error) {
                                                 [[FBSession activeSession] closeAndClearTokenInformation];
                                             } else {
                                                 [[FBSession activeSession] closeAndClearTokenInformation];
                                             }
                                         }];

4) The user goes away and another user (with another Facebook profile) restart the flow from point 1.

The problem is that when the share action is done I delete the current session with [[FBSession activeSession] closeAndClearTokenInformation];. The FBLoginVIew change its text to "Log in with Facebook" but if I tap to FBLoginVIewagain the Facebook app is already logged and I can't make a login with another profile.

I need to know if there is a way to logout the Facebook app programmatically.

Thank you very much!

MaTTP
  • 953
  • 2
  • 12
  • 27
  • letting users use one device and constantly login with their accounts will most likely be a problem. facebook detects it if many users login in a very short time on one device. it is better to let users use their own device (with qr tags, for example). – andyrandy Sep 19 '14 at 10:26
  • possible duplicate of [facebook-ios-sdk logout question](http://stackoverflow.com/questions/6226950/facebook-ios-sdk-logout-question) – Pavan Kotesh Sep 22 '14 at 14:10

1 Answers1

0

If you're building a kiosk app, you should set the loginBehavior in your FBLoginView to be FBSessionLoginBehaviorForcingWebView. This will use the in-app webview for login rather than doing a fast-app-switch over to the FB app. Usually, this is an inferior user experience, but for an app like yours, you need to bypass SSO since you can't force the user to log out of the Facebook app.

See https://developers.facebook.com/docs/reference/ios/current/class/FBLoginView#loginBehavior

Ming Li
  • 15,672
  • 3
  • 37
  • 35