Forum Xamarin.iOS

Will Apple reject my app for storing the IdentifierAsVendor?

Billy12ShovelsBilly12Shovels USUniversity ✭✭✭

Hello Forums,

I am using this method to store a consistent device ID(Credit to

 * The value of CurrentDevice.IdentifierForVendor changes if the app is removed and reinstalled.
 * Therefore some ID (the value of IdentifierForVendor) is stored to the keychain and
 * reused every time (even after a reinstall). See

String id;

String ServiceId = "KeyChainAccountStore";

//use the bundle identifier of the app to identifie the value in the keychain
String appId = NSBundle.MainBundle.InfoDictionary["CFBundleIdentifier"].ToString();

//Try to read the id from the keychain
var rec = new SecRecord(SecKind.GenericPassword)
    Service = ServiceId,
    Account = appId,

SecStatusCode res;
var match = SecKeyChain.QueryAsRecord(rec, out res);

//Store a new ID to the keychain
if (match?.Generic == null)
    //Get the vendor ID (does change after a reinstall of the app)
    var vendorId = UIKit.UIDevice.CurrentDevice.IdentifierForVendor.AsString().Replace("-", "");

    SecRecord record = new SecRecord(SecKind.GenericPassword)
        Service = ServiceId,
        Account = appId,
        Generic = NSData.FromString(vendorId),
        Accessible = SecAccessible.Always

    var statusCode = SecKeyChain.Add(record);

    if(statusCode != SecStatusCode.Success)
        Debug.WriteLine("Could not save key to KeyChain: " + statusCode);

    id = vendorId;
{   //Use ID from keychain
    id = match.Generic.ToString();

return id;

Will my application be rejected for doing so?


Sign In or Register to comment.