Hou*_*man 5 facebook facebook-graph-api ios
这是测试用例之一,需要进行验证。
- 有人通过应用设置从Facebook删除您的应用,然后重新访问您的应用。您的应用程序应该检测到此情况,并提示用户重新登录。转到您的应用程序,然后点击“使用Facebook登录”按钮。单击“确定”接受读取权限(在适用的情况下再次单击“确定”接受写入权限)。在Facebook上设置并删除您的应用重复步骤1-2,并验证Facebook登录是否有效
我发现没有办法实现这一目标。当我在Facebook中删除该应用程序时,我的iOS仍然认为该会话有效。在Stackoverflow上似乎就此进行了讨论。但是提供的解决方案似乎不起作用。
到目前为止,这是我要登录的内容。但是我无法检测到用户何时在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];
}
}
Run Code Online (Sandbox Code Playgroud)
如果用户转到 Facebook 设置并删除了应用程序,Facebook 会发布到您在应用程序设置中设置的“取消授权回调 URL”。这将包括与画布应用程序相同的签名请求,因此您可以从那里获取 ID,并执行您需要执行的任何操作来跟踪删除您的应用程序的用户。
| 归档时间: |
|
| 查看次数: |
653 次 |
| 最近记录: |