public void InitDeviceId(string deviceId = null) { //**Priority is** //Cached DeviceID (remains even after after app kill) //Static DeviceID (only when the app is running either backgroun/foreground) //User provided DeviceID //Generate Random DeviceID var storedDeviceId = PlayerPrefs.GetString("DeviceID"); DeviceId = !_countlyUtils.IsNullEmptyOrWhitespace(storedDeviceId) ? storedDeviceId : !_countlyUtils.IsNullEmptyOrWhitespace(DeviceId) ? DeviceId : !_countlyUtils.IsNullEmptyOrWhitespace(deviceId) ? deviceId : _countlyUtils.GetUniqueDeviceId(); //Set DeviceID in Cache if it doesn't already exists in Cache if (_countlyUtils.IsNullEmptyOrWhitespace(storedDeviceId)) { PlayerPrefs.SetString(Constants.DeviceIDKey, DeviceId); } }