From e13d4a6b9ca36a07154fb37074ec9e3ad7b7c596 Mon Sep 17 00:00:00 2001 From: Alex Tran Date: Fri, 11 Mar 2022 14:38:15 -0600 Subject: [PATCH] Show correct device type when registering new device --- .../shared/services/device_info.service.dart | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/mobile/lib/shared/services/device_info.service.dart b/mobile/lib/shared/services/device_info.service.dart index f1089e5c45..26810ca357 100644 --- a/mobile/lib/shared/services/device_info.service.dart +++ b/mobile/lib/shared/services/device_info.service.dart @@ -1,27 +1,18 @@ import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter_udid/flutter_udid.dart'; -import 'package:flutter/material.dart'; +import 'dart:io' show Platform; class DeviceInfoService { Future> getDeviceInfo() async { // Get device info DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); - String? deviceId = ""; + String deviceId = await FlutterUdid.consistentUdid; String deviceType = ""; - try { - deviceId = await FlutterUdid.consistentUdid; + if (Platform.isAndroid) { deviceType = "ANDROID"; - } catch (e) { - debugPrint("Not an android device"); - } - - try { - deviceId = await FlutterUdid.consistentUdid; + } else if (Platform.isIOS) { deviceType = "IOS"; - debugPrint("Device ID: $deviceId"); - } catch (e) { - debugPrint("Not an ios device"); } return {"deviceId": deviceId, "deviceType": deviceType};