Open praeclarum opened 11 years ago
If you also have the Xamarin.Auth component, you can delete it yourself. I have done it like this in a Xamarin.Forms app:
var theChangeAccountButton = new Button {
TextColor = Color.White,
Font = Font.OfSize (textFont, textSize),
Text = "Change account",
BackgroundColor = Color.Transparent,
};
string flickrUser ="";
if (accounts.Count () > 0) {
flickrUser = accounts.First ().Username;
theChangeAccountButton.Text = "Logout of " + flickrUser;
} else {
theChangeAccountButton.IsVisible = false;
}
theChangeAccountButton.Clicked += (sender, e) => {
var store = AccountStore.Create ();
IEnumerable<Account> accounts = store.FindAccountsForService ("Flickr");
Console.WriteLine("Number of flickr accounts before is " + accounts.Count().ToString());
Account thisAccount;
if(accounts.Count() > 0){
for(int i=0;i<accounts.Count();i++){
thisAccount = accounts.First();
store.Delete(thisAccount,"Flickr");
}
}
accounts = store.FindAccountsForService ("Flickr");
Console.WriteLine("Number of flickr accounts afterwards is " + accounts.Count());
if(accounts.Count() == 0){
theChangeAccountButton.IsVisible = false;
DisplayAlert("Flickr","You are logged out of "+flickrUser+".","OK");
}else{
DisplayAlert("Flickr","For some reason, that didn't work.","OK");
flickrUser = accounts.First ().Username;
theChangeAccountButton.Text = "Logout of " + flickrUser;
}
};
When there are no flickr users saved, the button is hidden. When there is at least one, the button shows "Logout of user@domain.com". Normally, there's just one, so handling multiple flickr accounts is just for robustness.
If an account goes bad, then we need a way to delete them from the account store.