Implement FCM [WIP]
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@@ -18,6 +19,8 @@ class Globals {
|
||||
String buildNumber = '';
|
||||
String platform = '';
|
||||
String hostname = '';
|
||||
String clientType = '';
|
||||
String deviceModel = '';
|
||||
|
||||
late SharedPreferences sharedPrefs;
|
||||
|
||||
@@ -31,6 +34,25 @@ class Globals {
|
||||
this.platform = Platform.operatingSystem;
|
||||
this.hostname = Platform.localHostname;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
this.clientType = 'ANDROID';
|
||||
this.deviceModel = (await DeviceInfoPlugin().androidInfo).model;
|
||||
} else if (Platform.isIOS) {
|
||||
this.clientType = 'IOS';
|
||||
this.deviceModel = (await DeviceInfoPlugin().iosInfo).model;
|
||||
} else if (Platform.isLinux) {
|
||||
this.clientType = 'LINUX';
|
||||
this.deviceModel = (await DeviceInfoPlugin().linuxInfo).prettyName;
|
||||
} else if (Platform.isWindows) {
|
||||
this.clientType = 'WINDOWS';
|
||||
this.deviceModel = (await DeviceInfoPlugin().windowsInfo).productName;
|
||||
} else if (Platform.isMacOS) {
|
||||
this.clientType = 'MACOS';
|
||||
this.deviceModel = (await DeviceInfoPlugin().macOsInfo).model;
|
||||
} else {
|
||||
this.clientType = '?';
|
||||
}
|
||||
|
||||
this.sharedPrefs = await SharedPreferences.getInstance();
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:simplecloudnotifier/api/api_client.dart';
|
||||
import 'package:simplecloudnotifier/models/client.dart';
|
||||
import 'package:simplecloudnotifier/models/key_token_auth.dart';
|
||||
import 'package:simplecloudnotifier/models/user.dart';
|
||||
import 'package:simplecloudnotifier/state/globals.dart';
|
||||
@@ -9,10 +10,19 @@ class UserAccount extends ChangeNotifier {
|
||||
User? _user;
|
||||
User? get user => _user;
|
||||
|
||||
Client? _client;
|
||||
Client? get client => _client;
|
||||
|
||||
KeyTokenAuth? _auth;
|
||||
KeyTokenAuth? get auth => _auth;
|
||||
|
||||
UserAccount() {
|
||||
static UserAccount? _singleton = UserAccount._internal();
|
||||
|
||||
factory UserAccount() {
|
||||
return _singleton ?? (_singleton = UserAccount._internal());
|
||||
}
|
||||
|
||||
UserAccount._internal() {
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -38,6 +48,16 @@ class UserAccount extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setClient(Client client) {
|
||||
_client = client;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void clearClient() {
|
||||
_client = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void load() {
|
||||
final uid = Globals().sharedPrefs.getString('auth.userid');
|
||||
final tok = Globals().sharedPrefs.getString('auth.token');
|
||||
|
Reference in New Issue
Block a user