ios - 如何检测是否有人从 facebook 中删除了该应用程序并重新访问该应用程序?

标签 ios facebook facebook-graph-api

这是测试用例之一,需要验证。

  1. Someone removes your app from Facebook via app settings and revisits your app. Your app should detect this and prompt the person to log back in. Go to your app and tap on the "Log in with Facebook” button Tap OK to accept the read permissions (and OK again to accept write permissions where applicable) Go to app settings on Facebook and remove your app Repeat steps 1-2 and verify that Facebook Login works

我没有找到实现这个的方法。当我删除 facebook 中的应用程序时,我的 iOS 仍然认为该 session 有效。在 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];
          }
   }

最佳答案

正如@Tom Kincaid 所说,您可以使用取消授权回调机制来接收从 FB 到您的后端端点之一的调用。请参阅 https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.1#deauth-callback 处的文档

您可以将 user_id 存储在一个单独的表中,或者在现有用户表或对象结构中有一个用于删除的标志。

然后,您的应用可以在加载时检查用户是否仍然“活跃”,或者是否被标记为已删除该应用,并采取相应措施。

关于ios - 如何检测是否有人从 facebook 中删除了该应用程序并重新访问该应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26076043/

相关文章:

facebook - 应用程序发布到用户墙 - Graph API 与 Open Graph

ios - Facebook 应用程序请求通知未出现

ios - 在 Swift 5 中使用 Graph API 显示用户的 Facebook 图片

iphone - 什么时候 NSURLResponse 不是 NSHTTPURLResponse?

c++ - 检测墙壁或平面(使用 OpenCV)?

ios - 解析 iOS 9 的 FacebookUtils 失败并出现 -canOpenURL 错误

javascript - 打开 'feed' 对话框时如何在没有访问 token 的情况下获取用户的名字?

android - 在没有用户登录 Facebook 的情况下从 Android 应用程序中的 Facebook 墙(公共(public))读取?

ios - 使用 Swift 仅向文本添加高亮/背景

android - CSS 无法在设备上运行