苹果在 Facebook 登录时拒绝应用程序

Posted

技术标签:

【中文标题】苹果在 Facebook 登录时拒绝应用程序【英文标题】:App rejection by apple on facebook login 【发布时间】:2014-04-29 17:59:46 【问题描述】:

我在我的应用程序中使用 facebook 登录并从 facebook 获取用户名和个人资料图片。我已经测试过,它最终运行良好,但苹果两次拒绝它。我没有发现任何错误。

这是苹果团队的错误:- “我们仍然发现,在运行 ios 7.1 的 iPad Air 和运行 iOS 7.1 的 iPhone 5s 在 Wi-Fi 和蜂窝网络上进行审查时,您的应用程序出现了一个或多个错误,这不符合 App Store 审查指南。 具体来说,当我们点击登录 Facebook 时,我们会收到消息说它想要连接,而当我们点击确定时,它不会前进并与 Facebook 连接。 "

这是我的代码

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;

self.login=[[ViewController alloc]init];
_nav = [[UINavigationController alloc] initWithRootViewController:self.login];



self.window.rootViewController = _nav;
[self.window makeKeyAndVisible];
// Override point for customization after application launch.

// Whenever a person opens the app, check for a cached session
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:@[@"basic_info", @"email", @"user_likes"]
                                       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];

                                      switch (state) 
                                          case FBSessionStateOpen:
                                              [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) 
                                                  if (error) 

                                                      NSLog(@"error:%@",error);


                                                  
                                                  else
                                                  
                                                      // retrive user's details at here as shown below


                                                      NSUserDefaults *storeData=[NSUserDefaults standardUserDefaults];
                                                      [storeData setObject:user.id forKey:@"user_id"];
                                                      [storeData setObject:user.name forKey:@"name"];

                                                  
                                              ];
                                              break;

                                          case FBSessionStateClosed:
                                          case FBSessionStateClosedLoginFailed:
                                              [FBSession.activeSession closeAndClearTokenInformation];
                                              break;

                                          default:
                                              break;
                                      



                                  ];

    // If there's no cached session, we will show a login button
 else 
    //UIButton *loginButton = [self.login loginButton];
    //[loginButton setTitle:@"Log in with Facebook" forState:UIControlStateNormal];

return YES;


  

  - (void)applicationWillResignActive:(UIApplication *)application
 
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
  

 - (void)applicationDidEnterBackground:(UIApplication *)application

// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
 

 - (void)applicationWillEnterForeground:(UIApplication *)application
 
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.



 // This method will handle ALL the session state changes in the app
 - (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];


// Handle errors
if (error)
    NSLog(@"Error");
    NSString *alertText;
    NSString *alertTitle;
    // If the error requires people using an app to make an action outside of the app in order to recover
    if ([FBErrorUtility shouldNotifyUserForError:error] == YES)
        alertTitle = @"Something went wrong";
        alertText = [FBErrorUtility userMessageForError:error];
        [self showMessage:alertText withTitle:alertTitle];
     else 

        // If the user cancelled login, do nothing
        if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryUserCancelled) 
            NSLog(@"User cancelled login");

            // Handle session closures that happen outside of the app
         else if ([FBErrorUtility errorCategoryForError:error] == FBErrorCategoryAuthenticationReopenSession)
            alertTitle = @"Session Error";
            alertText = @"Your current session is no longer valid. Please log in again.";
            [self showMessage:alertText withTitle:alertTitle];

            // For simplicity, here we just show a generic message for all other errors
            // You can learn how to handle other errors using our guide: https://developers.facebook.com/docs/ios/errors
         else 
            //Get more error information from the error
            NSDictionary *errorInformation = [[[error.userInfo objectForKey:@"com.facebook.sdk:ParsedJSONResponseKey"] objectForKey:@"body"] objectForKey:@"error"];

            // Show the user an error message
            alertTitle = @"Something went wrong";
            alertText = [NSString stringWithFormat:@"Please retry. \n\n If the problem persists contact us and mention this error code: %@", [errorInformation objectForKey:@"message"]];
            [self showMessage:alertText withTitle:alertTitle];
        
    
    // Clear this token
    [FBSession.activeSession closeAndClearTokenInformation];
    // Show the user the logged-out UI
    [self userLoggedOut];

  

// Show the user the logged-out UI
- (void)userLoggedOut
 
// Set the button title as "Log in with Facebook"
// UIButton *loginButton = [self.login loginButton];
//[loginButton setTitle:@"Log in with Facebook" forState:UIControlStateNormal];

// Confirm logout message
      //[self showMessage:@"You're now logged out" withTitle:@""];
  

 // Show the user the logged-in UI
- (void)userLoggedIn
 
// Set the button title as "Log out"
// UIButton *loginButton = self.login.loginButton;
//[loginButton setTitle:@"Log out" forState:UIControlStateNormal];

     FrontViewController *v=[[FrontViewController alloc]init];
RearViewController *rearViewController = [[RearViewController alloc] init];

UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:v];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearViewController];


SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.delegate = self;


[self.nav pushViewController:revealController animated:YES];



[self showMessage:@"You're now logged in" withTitle:@"Welcome!"];

  

  // Show an alert message
  - (void)showMessage:(NSString *)text withTitle:(NSString *)title
  
[[[UIAlertView alloc] initWithTitle:title
                            message:text
                           delegate:self
                  cancelButtonTitle:@"OK!"
                  otherButtonTitles:nil] show];
 

   // During the Facebook login flow, your app passes control to the Facebook iOS app or Facebook in a mobile browser.
  // After authentication, your app will be called back with the session information.
  // Override application:openURL:sourceApplication:annotation to call the FBsession object that handles the incoming URL

     - (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation
 
  return [FBSession.activeSession handleOpenURL:url];


- (void)applicationDidBecomeActive:(UIApplication *)application


// Handle the user leaving the app while the Facebook login dialog is being shown
// For example: when the user presses the iOS "home" button while the login dialog is active
   [FBAppCall handleDidBecomeActive];

在我的视图控制器中

  - (IBAction)buttonTouched:(id)sender
 
  // If the session state is any of the two "open" states when the button is clicked
  if (FBSession.activeSession.state == FBSessionStateOpen
    || FBSession.activeSession.state == FBSessionStateOpenTokenExtended) 

    // Close the session and remove the access token from the cache
    // The session state handler (in the app delegate) will be called automatically
    [FBSession.activeSession closeAndClearTokenInformation];

    // If the session state is not any of the two "open" states when the button is clicked
 else 
    // Open a session showing the user the login UI
    // You must ALWAYS ask for basic_info permissions when opening a session
    [FBSession openActiveSessionWithReadPermissions:@[@"basic_info", @"email", @"user_likes"]
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session, FBSessionState state, NSError *error) 

         // Retrieve the app delegate
         AppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
         // Call the app delegate's sessionStateChanged:state:error method to handle session state changes
         [appDelegate sessionStateChanged:session state:state error:error];

         switch (state) 
             case FBSessionStateOpen:
                 [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) 
                     if (error) 

                         NSLog(@"error:%@",error);


                     
                     else
                     
                         // retrive user's details at here as shown below
                         NSLog(@"FB user first name:%@",user.first_name);



                             NSUserDefaults *storeData=[NSUserDefaults standardUserDefaults];
                            [storeData setObject:user.id forKey:@"user_id"];
                            [storeData setObject:user.name forKey:@"name"];

                     


                 ];
                 break;

             case FBSessionStateClosed:
             case FBSessionStateClosedLoginFailed:
                 [FBSession.activeSession closeAndClearTokenInformation];
                 break;

             default:
                 break;
         

     ];

【问题讨论】:

当您运行您的应用并点击登录到 Facebook,然后点击连接时,它是继续登录,还是停止? 当我这样做时,它会继续使用 facebook,我可以进入应用程序并将图片分享到我的 facebook。 您是否尝试过删除测试版本并重新安装以查看是否可以复制他们的问题? 如果您尝试禁用连接会怎样? 在 SIM 中也试试,使用 64 位配置 【参考方案1】:

您在 developer.facebook.com 上的应用是否公开并可供所有用户使用?

状态应如下所示:

在其他情况下,如果您的应用的状态为 Developer Mode,则其他用户无法通过 Facebook 授权。

【讨论】:

是的,它是公开的,所有用户都可以使用【参考方案2】:

我也有同样的问题。虽然是 Flutter 应用,但用例是一样的。

在我看来,一切都按预期进行

Fb 应用已正确设置 iOS 和 Bundle ID

FB 应用是公开的

但苹果审核团队仍然拒绝它。我要求他们提供更多屏幕截图,并且屏幕截图清楚地显示了 FB 弹出窗口的“继续”对话框。所以我不明白他们为什么拒绝它。

【讨论】:

以上是关于苹果在 Facebook 登录时拒绝应用程序的主要内容,如果未能解决你的问题,请参考以下文章

Apple在应用程序中拒绝了facebook登录应用程序

Apple 拒绝了在应用程序中使用 facebook 登录的应用程序

应用商店拒绝了有关添加苹果登录和应用内购买的应用

代号一。使用 Webview 组件登录 Facebook

谷歌身份验证时苹果应用被拒绝(元数据)

拒绝权限后登录 Facebook