2016-01-20 59 views
2

我使用Azure移动服务Facebook身份验证创建了.NET应用程序。我用凭证:Azure移动服务 - Facebook登出

// Login with the identity provider. 
     user = await App.MobileService 
      .LoginAsync(provider); 

     // Create and store the user credentials. 
     credential = new PasswordCredential(provider, 
      user.UserId, user.MobileServiceAuthenticationToken); 
     vault.Add(credential); 

如何注销?

回答

3

使用MobileServiceClient.Logout

此方法在调用MobileServiceClient.Logout方法之前清除由身份提供者设置的任何Cookie,以便将用户从Azure移动服务实例中注销。

下面的代码示例示出了用于iOS平台登出方法:

public void Logout() 
{ 
    foreach (var cookie in NSHttpCookieStorage.SharedStorage.Cookies) { 
    NSHttpCookieStorage.SharedStorage.DeleteCookie (cookie); 
    } 

    App.Client.Logout(); 
} 

代码为Android平台:

public void Logout() 
{ 
    CookieManager.Instance.RemoveAllCookie(); 
    App.Client.Logout(); 
} 

代码为Windows Phone 8.1平台:

public void Logout() 
{ 
    ... 
    AzureTodo.App.Client.Logout(); 
}