2016-08-03 76 views
0

我有OneDrive问题。如何注销iOS OneDrive权限UI

我在本站点测试了OneDrive示例应用程序。 https://github.com/OneDrive/onedrive-sdk-ios

步骤:

  1. '登录' 按钮点击。和登录。

  2. 显示权限UI。并点击“取消”或“否”按钮。 enter image description here

  3. 然后权限UI关闭。然后重新点击“登录”。

  4. 然后再次显示权限UI。

如果我想登录其他帐户,我必须在权限界面中点击“是”按钮。并注销并重新登录。

如何在权限界面中点击“取消”或“否”按钮时注销。

这是代码:

[ODClient authenticatedClientWithCompletion:^(ODClient *client, NSError *error){ 
    if (!error){ 
     self.client = client; 
     [self loadChildren]; 
     dispatch_async(dispatch_get_main_queue(), ^(){ 
      self.navigationItem.rightBarButtonItem = self.actions; 
     }); 
    } 
    else{ 
     [self showErrorAlert:error]; 
    } 
}]; 

当我点击“取消”或许可UI“否”按钮,误差不为零。所以客户端(ODClient)是零。 然后可以调用注销方法。 (self.client为零)

- (void)signOutAction{ 
    [self.client signOutWithCompletion:^(NSError *signOutError){ 
     self.items = nil; 
     self.items = [NSMutableDictionary dictionary]; 
     self.itemsLookup = nil; 
     self.itemsLookup = [NSMutableArray array]; 
     self.client = nil; 
     self.currentItem = nil; 
     self.title = @"OneDrive"; 
     dispatch_async(dispatch_get_main_queue(), ^(){ 
      self.navigationItem.hidesBackButton = YES; 
      self.navigationItem.rightBarButtonItem = self.signIn; 
      // Reload from main thread 
      [self.collectionView reloadData]; 
     }); 
    }]; 
} 

回答

0

我找到了解决方法。

[ODClient clientWithCompletion:^(ODClient *client, NSError *error) 
{ 
    if (error == nil) 
    { 
     self.client = client; 
    } 
    else 
    { 
     NSHTTPCookieStorage* storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
     for(NSHTTPCookie* cookie in [storage cookies]) 
     { 
      [storage deleteCookie:cookie]; 
     } 
    } 
}];