简体   繁体   English

iOS Facebook SDK分享照片并从Facebook应用注销后

[英]iOS Facebook SDK share photo and after logout from Facebook app

I need to install my app on a totem in an exhibition stand. 我需要将我的应用安装在展位的图腾上。 The application flow is: 申请流程为:

1) User takes a photo 1)用户拍照

2) User taps on a FBLoginView that open the Facebook app. 2)用户点击打开Facebook应用程序的FBLoginView The user makes the login and the Facebook app automatically returns to my app. 用户进行登录,Facebook应用程序自动返回我的应用程序。

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. 3)用户点击UIButton发布照片,然后再次打开Facebook应用。 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. 4)用户离开,另一个用户(具有另一个Facebook个人资料)从点1重新开始流程。

The problem is that when the share action is done I delete the current session with [[FBSession activeSession] closeAndClearTokenInformation]; 问题是,完成共享操作后,我将使用[[FBSession activeSession] closeAndClearTokenInformation];删除当前会话[[FBSession activeSession] closeAndClearTokenInformation]; . The FBLoginVIew change its text to "Log in with Facebook" but if I tap to FBLoginVIew again the Facebook app is already logged and I can't make a login with another profile. FBLoginVIew将其文本更改为“使用Facebook登录”,但是如果再次点击FBLoginVIew ,则Facebook应用已被登录,并且我无法使用其他配置文件进行登录。

I need to know if there is a way to logout the Facebook app programmatically. 我需要知道是否可以通过编程方式注销Facebook应用程序。

Thank you very much! 非常感谢你!

If you're building a kiosk app, you should set the loginBehavior in your FBLoginView to be FBSessionLoginBehaviorForcingWebView. 如果您要构建信息亭应用,则应在FBLoginView中将loginBehavior设置为FBSessionLoginBehaviorForcingWebView。 This will use the in-app webview for login rather than doing a fast-app-switch over to the FB app. 这将使用应用程序内Web视图进行登录,而不是快速将应用程序切换到FB应用程序。 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. 通常,这是次等的用户体验,但是对于像您这样的应用程序,您需要绕过SSO,因为您不能强制用户退出Facebook应用程序。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM