2016-01-20 55 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(); 
}