Skip to content

Instantly share code, notes, and snippets.

@HeathHopkins
Last active December 16, 2015 19:00
Show Gist options
  • Save HeathHopkins/5482166 to your computer and use it in GitHub Desktop.
Save HeathHopkins/5482166 to your computer and use it in GitHub Desktop.
Removes stored Facebook records created by Xamarin.Social
public static void ClearFacebookRecords()
{
var records = Social.FacebookRecords;
for (var i = 0; i < records.Length; i++)
{
var delQuery = new SecRecord(SecKind.GenericPassword);
delQuery.Service = "Facebook";
delQuery.Account = records[i].Account;
Console.WriteLine("Removing stored Facebook account: " + records[i].Account);
var statusCode = SecKeyChain.Remove(delQuery);
if (statusCode != SecStatusCode.Success)
Console.WriteLine("unable to remove keychain record for " + records[i].Account);
}
}
public static SecRecord[] FacebookRecords
{
get
{
var query = new SecRecord(SecKind.GenericPassword)
{
Service = "Facebook"
};
SecStatusCode result;
var results = SecKeyChain.QueryAsRecord(query, 1000, out result);
return results ?? new SecRecord[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment