【发布时间】:2014-11-22 10:30:27
【问题描述】:
这是需要验证的测试用例之一。
- 有人通过应用设置从 Facebook 删除您的应用并重新访问您的应用。您的应用程序应该检测到这一点并提示该人 重新登录。转到您的应用并点击“使用 Facebook 登录” 按钮 点击 OK 接受读取权限(再次点击 OK 接受 在适用的情况下写入权限)转到 Facebook 上的应用设置,然后 删除您的应用 重复步骤 1-2 并验证 Facebook 登录是否有效
我没有找到实现这一点的方法。当我在 facebook 中删除应用程序时,我的 iOS 仍然认为会话有效。在 Stackoverflow 上似乎有一个 discussion 与此有关。但提供的解决方案似乎不起作用。
这是我到目前为止登录的内容。但我无法检测到用户何时在 facebook 上删除了该应用程序。请问有什么建议吗?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
NSLog(@"Found a cached session");
// If there's one, just open the session silently, without showing the user the login UI
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile"]
allowLoginUI:NO
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
// Handler for session state changes
// This method will be called EACH time the session state changes,
// also for intermediate states and NOT just when the session open
[self sessionStateChanged:session state:state error:error];
}];
// If there's no cached session, we will show a login button
} else {
UIButton *loginButton = [self.customLoginViewController loginButton];
[loginButton setTitle:@"Log in with Facebook" forState:UIControlStateNormal];
}
}
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
// If the session was opened successfully
if (!error && state == FBSessionStateOpen){
NSLog(@"Session opened");
// Show the user the logged-in UI
[self userLoggedIn];
return;
}
if (state == FBSessionStateClosed || state == FBSessionStateClosedLoginFailed){
// If the session is closed
NSLog(@"Session closed");
// Show the user the logged-out UI
[self userLoggedOut];
}
}
【问题讨论】:
-
关于此的任何更新
标签: ios facebook facebook-graph-api