Közös projekt szinkronizációja
This commit is contained in:
@@ -14,6 +14,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:terepi_seged/services/app_logger.dart';
|
||||
import 'package:terepi_seged/services/firebase_logger.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@@ -58,8 +59,8 @@ class DeviceIdentityService extends GetxService {
|
||||
super.onReady();
|
||||
await _load();
|
||||
// Háttérben regisztrálás — nem blokkolja az UI-t
|
||||
unawaited(_registerDevice());
|
||||
_isReady = true;
|
||||
unawaited(registerDevice());
|
||||
|
||||
FirebaseLogger.setDeviceIdentifier(info.deviceId, deviceLabel.value);
|
||||
FirebaseLogger.setKey('model', model);
|
||||
@@ -84,6 +85,15 @@ class DeviceIdentityService extends GetxService {
|
||||
final storedLabel = results[2] as String?;
|
||||
final android = results[3] as AndroidDeviceInfo;
|
||||
final pkg = results[4] as PackageInfo;
|
||||
String platform = '';
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
platform = 'Android';
|
||||
} else if (Platform.isIOS) {
|
||||
platform = 'iOS';
|
||||
} else if (Platform.isMacOS) {
|
||||
platform = 'macOS';
|
||||
}
|
||||
|
||||
// ANDROID_ID — MethodChannel-en keresztül (Settings.Secure.ANDROID_ID)
|
||||
final androidId = await _getAndroidId() ?? android.fingerprint;
|
||||
@@ -92,6 +102,7 @@ class DeviceIdentityService extends GetxService {
|
||||
info = DeviceInfoModel(
|
||||
deviceId: androidId,
|
||||
appInstanceId: instanceId,
|
||||
platform: platform,
|
||||
manufacturer: android.manufacturer,
|
||||
model: android.model,
|
||||
brand: android.brand,
|
||||
@@ -106,6 +117,12 @@ class DeviceIdentityService extends GetxService {
|
||||
// Label: tárolt érték > rendszer neve
|
||||
deviceLabel.value = storedLabel ?? systemName;
|
||||
print('Device label: ${deviceLabel.value}');
|
||||
print('DeviceId: ${info.deviceId}');
|
||||
print('AppInstanceId: ${info.appInstanceId}');
|
||||
print('SystemDeviceName: ${info.systemDeviceName}');
|
||||
print('AppVersion: ${info.appVersion}');
|
||||
print('buildNumber: ${info.buildNumber}');
|
||||
print('model: ${info.model}');
|
||||
}
|
||||
|
||||
// ── SecureStorage műveletek ───────────────────────────────────────
|
||||
@@ -162,13 +179,29 @@ class DeviceIdentityService extends GetxService {
|
||||
deviceLabel.value = trimmed;
|
||||
}
|
||||
|
||||
unawaited(_registerDevice());
|
||||
unawaited(registerDevice());
|
||||
}
|
||||
|
||||
// ── Supabase regisztráció ─────────────────────────────────────────
|
||||
|
||||
Future<void> _registerDevice() async {
|
||||
// await Supabase.instance.client
|
||||
Future<void> registerDevice() async {
|
||||
final user = Supabase.instance.client.auth.currentUser;
|
||||
if (user == null || deviceId.isEmpty) return;
|
||||
|
||||
await Supabase.instance.client.from('terepi_seged_devices').upsert({
|
||||
'id': appInstanceId,
|
||||
'user_id': user.id,
|
||||
'name': info.systemDeviceName,
|
||||
'device_id': deviceId,
|
||||
'platform': info.platform,
|
||||
'model': model,
|
||||
'os_version': info.osVersion,
|
||||
'app_version': appInfo,
|
||||
'last_seen_at': DateTime.now().toUtc().toIso8601String()
|
||||
});
|
||||
|
||||
//
|
||||
// // await Supabase.instance.client
|
||||
// .from('devices')
|
||||
// .upsert(
|
||||
// info.toRegistrationMap(label: deviceLabel.value),
|
||||
|
||||
Reference in New Issue
Block a user