createRegistration method
Creates a SmartphoneRegistration with details of this phone.
deviceId defaults to DeviceInfoService.deviceID and
deviceDisplayName to a name built from platform, model, and SDK.
Logs a warning if DeviceInfoService is not initialized.
Implementation
@override
SmartphoneRegistration createRegistration({String? deviceId, String? deviceDisplayName}) {
if (!DeviceInfoService().initialized) {
warning(
'$runtimeType - Initialize DeviceInfo before creating a Smartphone registration '
'in order to get correct device specific information.',
);
}
final id = deviceId ?? DeviceInfoService().deviceID;
final platform = DeviceInfoService().platform;
final hardware = DeviceInfoService().hardware;
final deviceManufacturer = DeviceInfoService().deviceManufacturer;
final deviceModel = DeviceInfoService().deviceModel;
final sdk = DeviceInfoService().sdk;
final displayName =
deviceDisplayName ??
((Platform.isAndroid)
? '$platform (${deviceManufacturer?.toUpperCase()}) - $deviceModel [SDK: $sdk]'
: '$platform - $hardware [SDK: $sdk]');
return SmartphoneRegistration(
deviceId: id,
deviceDisplayName: displayName,
platform: platform,
hardwareName: hardware,
deviceManufacturer: deviceManufacturer,
deviceModel: deviceModel,
operatingSystem: DeviceInfoService().operatingSystemName,
sdk: sdk,
release: DeviceInfoService().release,
);
}