In my app I have two methods which help me save and get values from keychain
public static void StoreKeysInKeychain(string key, string value)
{
DeleteKeyFromKeychain(key);
var s = new SecRecord(SecKind.GenericPassword)
{
ValueData = NSData.FromString(value),
Generic = NSData.FromString(key)
};
SecKeyChain.Add(s);
Console.WriteLine(GetRecordsFromKeychain(key));
}
public static string GetRecordsFromKeychain(string key)
{
SecStatusCode res;
var rec = new SecRecord(SecKind.GenericPassword)
{
Generic = NSData.FromString(key)
};
var match = SecKeyChain.QueryAsRecord(rec, out res);
if (match != null)
return match.ValueData.ToString();
return "Error";
}
I'm saving there two values and for some reason when I try to get any of them I get an "Error" string instead of the value. The same code previously worked without any problems, but then I added another parameter to store in the keychain and renamed both