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

Ios 苹果在facebook登录时拒绝应用程序,ios,facebook-graph-api,Ios,Facebook Graph Api,我在应用程序中使用facebook登录,并从facebook获取用户名和个人资料图片。我已经测试过了,它在我这边运行得很好,但苹果已经两次拒绝了它。在我这方面我没有发现任何错误 这是苹果团队的错误:- “我们仍然发现,在运行iOS 7.1的iPad Air和运行iOS 7.1的iPhone 5s上,在Wi-Fi和蜂窝网络上,您的应用程序都出现了一个或多个漏洞,这不符合应用商店审查指南。 具体来说,当我们点击“登录Facebook”时,我们会收到一条消息,说它想连接,而当我们点击“确定”时,它不会

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

这是苹果团队的错误:- “我们仍然发现,在运行iOS 7.1的iPad Air和运行iOS 7.1的iPhone 5s上,在Wi-Fi和蜂窝网络上,您的应用程序都出现了一个或多个漏洞,这不符合应用商店审查指南。 具体来说,当我们点击“登录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];
}
-(BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项
{
UIWindow*窗口=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]边界]];
self.window=窗口;
self.login=[[ViewController alloc]init];
_nav=[[UINavigationController alloc]initWithRootViewController:self.login];
self.window.rootViewController=\u nav;
[self.window makeKeyAndVisible];
//应用程序启动后自定义的覆盖点。
//每当有人打开应用程序时,请检查缓存的会话
如果(FBSession.activeSession.state==FBSessionStateCreatedTokenLoaded){
NSLog(@“找到缓存的会话”);
//如果有,只需以静默方式打开会话,而不向用户显示登录UI
[FBSession openActiveSessionWithReadPermissions:@[@“基本信息”,“电子邮件”,“用户喜欢”]
阿洛洛洛吉努伊:没有
completionHandler:^(FBSession*会话,FBSessionState状态,NSError*错误){
//会话状态更改的处理程序
//每次会话状态更改时都会调用此方法,
//也适用于中间状态,而不仅仅是会话打开时
[自会话状态已更改:会话状态:状态错误:错误];
开关(状态){
案例FBSessionStateOpen:
[[FBRequest requestForMe]startWithCompletionHandler:^(FBRequestConnection*连接,NSDictionary*用户,NSError*错误){
如果(错误){
NSLog(@“错误:%@”,错误);
}
其他的
{
//在此处检索用户详细信息,如下所示
NSUserDefaults*storeData=[NSUserDefaults standardUserDefaults];
[storeData setObject:user.id forKey:@“user_id”];
[storeData setObject:user.name forKey:@“name”];
}
}];
打破
案件审理结束:
案例FBSessionStateClosedLogin失败:
[FBSession.activeSession closeAndClearTokenInformation];
打破
违约:
打破
}
}];
//如果没有缓存会话,我们将显示一个登录按钮
}否则{
//UIButton*loginButton=[self.login loginButton];
//[登录按钮设置标题:@“使用Facebook登录”状态:UIControlStateNormal];
}
返回YES;
}
-(无效)应用程序将重新签名:(UIApplication*)应用程序
{
//当应用程序即将从活动状态移动到非活动状态时发送。这可能发生在某些类型的临时中断(如来电或短信)或用户退出应用程序并开始转换到后台状态时。
//使用此方法暂停正在进行的任务、禁用计时器和降低OpenGL ES帧速率。游戏应使用此方法暂停游戏。
}
-(无效)应用程序标识符背景:(UIApplication*)应用程序
{
//使用此方法释放共享资源、保存用户数据、使计时器无效,并存储足够的应用程序状态信息,以便在应用程序稍后终止时将其恢复到当前状态。
//如果您的应用程序支持后台执行,则会调用此方法而不是applicationWillTerminate:当用户退出时。
}
-(无效)应用程序将进入前台:(UIApplication*)应用程序
{
//作为从后台转换到非活动状态的一部分调用;在这里,您可以撤消进入后台时所做的许多更改。
}
//此方法将处理应用程序中的所有会话状态更改
-(void)会话状态已更改:(FBSession*)会话状态:(FBSessionState)状态错误:(NSError*)错误
{
//如果会话已成功打开
如果(!error&&state==FBSessionStateOpen){
NSLog(@“会话已打开”);
//向用户显示已登录的UI
[self-userLoggedIn];
返回;
}
如果(状态==FBSessionStateClosed | |状态==FBSessionStateClosedLoginFailed){
//如果会话已关闭
NSLog(@“会话已关闭”);
//向用户显示已注销的UI
[self-userLoggedOut];
}
//处理错误
如果(错误){
NSLog(@“错误”);
NSString*警报文本;
NSString*警报标题;
//如果错误要求使用应用程序的用户在应用程序之外执行操作以进行恢复
如果([FBErrorUtility shouldNotifyUserForError:error]==是){
警觉的
  - (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;
         }

     }];
}