From 1fc84099feed64391942a0cbb5766a5ab8cdfbef Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 13 Oct 2024 20:03:36 +0800 Subject: [PATCH] :recycle: Better push token uuid --- lib/providers/websocket.dart | 34 ++----------------- linux/flutter/generated_plugin_registrant.cc | 4 +++ linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ pubspec.lock | 12 +++++-- pubspec.yaml | 1 + .../flutter/generated_plugin_registrant.cc | 3 ++ windows/flutter/generated_plugins.cmake | 1 + 8 files changed, 25 insertions(+), 33 deletions(-) diff --git a/lib/providers/websocket.dart b/lib/providers/websocket.dart index 04a2b96..910861d 100644 --- a/lib/providers/websocket.dart +++ b/lib/providers/websocket.dart @@ -3,10 +3,9 @@ import 'dart:convert'; import 'dart:developer'; import 'dart:io'; -import 'package:crypto/crypto.dart'; -import 'package:device_info_plus/device_info_plus.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; +import 'package:flutter_udid/flutter_udid.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:solian/exceptions/request.dart'; @@ -172,7 +171,6 @@ class WebSocketProvider extends GetxController { log("Unable to active push notifications, couldn't get device uuid"); return; } else { - deviceUuid = md5.convert(utf8.encode(deviceUuid)).toString(); log('Device UUID is $deviceUuid'); } @@ -198,33 +196,7 @@ class WebSocketProvider extends GetxController { } Future _getDeviceUuid() async { - DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); - if (PlatformInfo.isWeb) { - final webInfo = await deviceInfo.webBrowserInfo; - return webInfo.vendor! + - webInfo.userAgent! + - webInfo.hardwareConcurrency.toString(); - } - if (PlatformInfo.isAndroid) { - final androidInfo = await deviceInfo.androidInfo; - return androidInfo.id; - } - if (PlatformInfo.isIOS) { - final iosInfo = await deviceInfo.iosInfo; - return iosInfo.identifierForVendor!; - } - if (PlatformInfo.isLinux) { - final linuxInfo = await deviceInfo.linuxInfo; - return linuxInfo.machineId!; - } - if (PlatformInfo.isWindows) { - final windowsInfo = await deviceInfo.windowsInfo; - return windowsInfo.deviceId; - } - if (PlatformInfo.isMacOS) { - final macosInfo = await deviceInfo.macOsInfo; - return macosInfo.systemGUID; - } - return null; + if (PlatformInfo.isWeb) return null; + return await FlutterUdid.consistentUdid; } } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index fca9c2f..d986dc0 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); + g_autoptr(FlPluginRegistrar) flutter_udid_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterUdidPlugin"); + flutter_udid_plugin_register_with_registrar(flutter_udid_registrar); g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin"); flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 885d4ce..044f50f 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_linux flutter_acrylic flutter_secure_storage_linux + flutter_udid flutter_webrtc media_kit_libs_linux media_kit_video diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 7832c8c..b83c970 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -15,6 +15,7 @@ import firebase_crashlytics import firebase_messaging import flutter_local_notifications import flutter_secure_storage_macos +import flutter_udid import flutter_webrtc import gal import in_app_review @@ -45,6 +46,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) + FlutterUdidPlugin.register(with: registry.registrar(forPlugin: "FlutterUdidPlugin")) FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin")) GalPlugin.register(with: registry.registrar(forPlugin: "GalPlugin")) InAppReviewPlugin.register(with: registry.registrar(forPlugin: "InAppReviewPlugin")) diff --git a/pubspec.lock b/pubspec.lock index 6153eea..6931c92 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -783,10 +783,10 @@ packages: dependency: "direct main" description: name: flutter_markdown - sha256: e17575ca576a34b46c58c91f9948891117a1bd97815d2e661813c7f90c647a78 + sha256: bd9c475d9aae256369edacafc29d1e74c81f78a10cdcdacbbbc9e3c43d009e4a url: "https://pub.dev" source: hosted - version: "0.7.3+2" + version: "0.7.4" flutter_native_splash: dependency: "direct dev" description: @@ -888,6 +888,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.2.0" + flutter_udid: + dependency: "direct main" + description: + name: flutter_udid + sha256: "63384bd96203aaefccfd7137fab642edda18afede12b0e9e1a2c96fe2589fd07" + url: "https://pub.dev" + source: hosted + version: "3.0.0" flutter_web_plugins: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index e93f4ec..43953ea 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -83,6 +83,7 @@ dependencies: action_slider: ^0.7.0 in_app_review: ^2.0.9 syntax_highlight: ^0.4.0 + flutter_udid: ^3.0.0 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index f3f9893..e3b8ac0 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("FlutterAcrylicPlugin")); FlutterSecureStorageWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); + FlutterUdidPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterUdidPluginCApi")); FlutterWebRTCPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterWebRTCPlugin")); GalPluginCApiRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index f09bc38..c5936fd 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -9,6 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST firebase_core flutter_acrylic flutter_secure_storage_windows + flutter_udid flutter_webrtc gal livekit_client