Exemplo n.º 1
0
        private static void _Init(object sender = null, EventArgs e = null)
        {
            string oldID = iCloudID;

            object token = null;

            if (NSFileManager.InstancesRespondToSelector("ubiquityIdentityToken"))
            {
                token = NSFileManager.DefaultManager().UbiquityIdentityToken();
            }

            if (token == null)
            {
                iCloudID = null;
                _userDefaults.RemoveObject(ID_KEY);
            }
            else
            {
                NSData data = NSKeyedArchiver.ArchivedData(token);
                iCloudID = Convert.ToBase64String(data.ToByteArray());
                _userDefaults.SetObject(iCloudID, ID_KEY);
            }

            Synchronize();

            if (iCloudID != oldID)
            {
                if (_accountChangedHandlers != null)
                {
                    _accountChangedHandlers(null, EventArgs.Empty);
                }
            }
        }