getDeviceModel static method
Implementation
static Future<String> getDeviceModel() async {
//Note: Taboola Android SDK runs a process on BuildConfig.Model before returning its value, will be simulated here.
if (TextUtils.isEmptyOrNull(_model)) {
if (dartIo.Platform.isAndroid) {
TBLAndroidDevice androidDeviceInfo =
await _deviceInfoPlugin.androidInfo;
String? nativeModel = androidDeviceInfo.model;
String? nativeManufacturer = androidDeviceInfo.manufacturer;
Pattern pattern = RegExp(nativeManufacturer ??
''); // convert to non-null string and create pattern
//Some devices start with
if (nativeModel != null && nativeModel.startsWith(pattern)) {
_model = TextUtils.capitalize(nativeModel);
} else {
_model =
'${TextUtils.capitalize(nativeManufacturer ?? "")} $nativeModel';
}
//Html escape value
_model = HtmlEscape().convert(_model);
}
//Note: iOS returns model only, as manufacturer is always Epel. .. .
if (dartIo.Platform.isIOS) {
TBLIosDevice iosDeviceInfo = await _deviceInfoPlugin.iosInfo;
_model = iosDeviceInfo.model ?? "";
}
}
return _model;
}