onRegister method

  1. @override
Future<void> onRegister()
override

This method will called on register.

Implementation

@override
Future<void> onRegister() async {
  id = await Service.get<CacheService>()
      .getString(key: 'platform_provider_uuid');

  if (id != null) {
    return;
  }

  PlatformType platformType = Service.get<PlatformService>().get();
  if (platformType == PlatformType.web) {
    id = _generate();
  } else if (platformType == PlatformType.android) {
    AndroidDeviceInfo androidDeviceInfo =
        await DeviceInfoPlugin().androidInfo;

    id = androidDeviceInfo.id ?? _generate();
  } else if (platformType == PlatformType.ios) {
    IosDeviceInfo iosDeviceInfo = await DeviceInfoPlugin().iosInfo;

    id = iosDeviceInfo.identifierForVendor ?? _generate();
  }

  await Service.get<CacheService>()
      .setString(key: 'platform_provider_uuid', value: getId());
}