Notifications (android via local) work
This commit is contained in:
@@ -10,6 +10,7 @@ class ApplicationLog {
|
||||
static void debug(String message, {String? additional, StackTrace? trace}) {
|
||||
(additional != null && additional != '') ? print('[DEBUG] ${message}: ${additional}') : print('[DEBUG] ${message}');
|
||||
|
||||
if (!Hive.isBoxOpen('scn-logs')) return;
|
||||
Hive.box<SCNLog>('scn-logs').add(SCNLog(
|
||||
id: Xid().toString(),
|
||||
timestamp: DateTime.now(),
|
||||
@@ -23,6 +24,7 @@ class ApplicationLog {
|
||||
static void info(String message, {String? additional, StackTrace? trace}) {
|
||||
(additional != null && additional != '') ? print('[INFO] ${message}: ${additional}') : print('[INFO] ${message}');
|
||||
|
||||
if (!Hive.isBoxOpen('scn-logs')) return;
|
||||
Hive.box<SCNLog>('scn-logs').add(SCNLog(
|
||||
id: Xid().toString(),
|
||||
timestamp: DateTime.now(),
|
||||
@@ -36,6 +38,7 @@ class ApplicationLog {
|
||||
static void warn(String message, {String? additional, StackTrace? trace}) {
|
||||
(additional != null && additional != '') ? print('[WARN] ${message}: ${additional}') : print('[WARN] ${message}');
|
||||
|
||||
if (!Hive.isBoxOpen('scn-logs')) return;
|
||||
Hive.box<SCNLog>('scn-logs').add(SCNLog(
|
||||
id: Xid().toString(),
|
||||
timestamp: DateTime.now(),
|
||||
@@ -49,6 +52,7 @@ class ApplicationLog {
|
||||
static void error(String message, {String? additional, StackTrace? trace}) {
|
||||
(additional != null && additional != '') ? print('[ERROR] ${message}: ${additional}') : print('[ERROR] ${message}');
|
||||
|
||||
if (!Hive.isBoxOpen('scn-logs')) return;
|
||||
Hive.box<SCNLog>('scn-logs').add(SCNLog(
|
||||
id: Xid().toString(),
|
||||
timestamp: DateTime.now(),
|
||||
@@ -62,6 +66,7 @@ class ApplicationLog {
|
||||
static void fatal(String message, {String? additional, StackTrace? trace}) {
|
||||
(additional != null && additional != '') ? print('[FATAL] ${message}: ${additional}') : print('[FATAL] ${message}');
|
||||
|
||||
if (!Hive.isBoxOpen('scn-logs')) return;
|
||||
Hive.box<SCNLog>('scn-logs').add(SCNLog(
|
||||
id: Xid().toString(),
|
||||
timestamp: DateTime.now(),
|
||||
|
@@ -32,8 +32,6 @@ class FBMessage extends HiveObject implements FieldDebuggable {
|
||||
final String? messageType;
|
||||
@HiveField(8)
|
||||
final bool mutableContent;
|
||||
@HiveField(9)
|
||||
final RemoteNotification? notification;
|
||||
@HiveField(10)
|
||||
final DateTime? sentTime;
|
||||
@HiveField(11)
|
||||
@@ -54,7 +52,7 @@ class FBMessage extends HiveObject implements FieldDebuggable {
|
||||
@HiveField(25)
|
||||
final String? notificationAndroidLink;
|
||||
@HiveField(26)
|
||||
final AndroidNotificationPriority? notificationAndroidPriority;
|
||||
final String? notificationAndroidPriority;
|
||||
@HiveField(27)
|
||||
final String? notificationAndroidSmallIcon;
|
||||
@HiveField(28)
|
||||
@@ -62,14 +60,14 @@ class FBMessage extends HiveObject implements FieldDebuggable {
|
||||
@HiveField(29)
|
||||
final String? notificationAndroidTicker;
|
||||
@HiveField(30)
|
||||
final AndroidNotificationVisibility? notificationAndroidVisibility;
|
||||
final String? notificationAndroidVisibility;
|
||||
@HiveField(31)
|
||||
final String? notificationAndroidTag;
|
||||
|
||||
@HiveField(40)
|
||||
final String? notificationAppleBadge;
|
||||
@HiveField(41)
|
||||
final AppleNotificationSound? notificationAppleSound;
|
||||
final String? notificationAppleSound;
|
||||
@HiveField(42)
|
||||
final String? notificationAppleImageUrl;
|
||||
@HiveField(43)
|
||||
@@ -109,7 +107,6 @@ class FBMessage extends HiveObject implements FieldDebuggable {
|
||||
required this.messageId,
|
||||
required this.messageType,
|
||||
required this.mutableContent,
|
||||
required this.notification,
|
||||
required this.sentTime,
|
||||
required this.threadId,
|
||||
required this.ttl,
|
||||
@@ -152,7 +149,6 @@ class FBMessage extends HiveObject implements FieldDebuggable {
|
||||
this.messageId = rmsg.messageId,
|
||||
this.messageType = rmsg.messageType,
|
||||
this.mutableContent = rmsg.mutableContent,
|
||||
this.notification = rmsg.notification,
|
||||
this.sentTime = rmsg.sentTime,
|
||||
this.threadId = rmsg.threadId,
|
||||
this.ttl = rmsg.ttl,
|
||||
@@ -162,14 +158,14 @@ class FBMessage extends HiveObject implements FieldDebuggable {
|
||||
this.notificationAndroidCount = rmsg.notification?.android?.count,
|
||||
this.notificationAndroidImageUrl = rmsg.notification?.android?.imageUrl,
|
||||
this.notificationAndroidLink = rmsg.notification?.android?.link,
|
||||
this.notificationAndroidPriority = rmsg.notification?.android?.priority,
|
||||
this.notificationAndroidPriority = rmsg.notification?.android?.priority?.toString(),
|
||||
this.notificationAndroidSmallIcon = rmsg.notification?.android?.smallIcon,
|
||||
this.notificationAndroidSound = rmsg.notification?.android?.sound,
|
||||
this.notificationAndroidTicker = rmsg.notification?.android?.ticker,
|
||||
this.notificationAndroidVisibility = rmsg.notification?.android?.visibility,
|
||||
this.notificationAndroidVisibility = rmsg.notification?.android?.visibility?.toString(),
|
||||
this.notificationAndroidTag = rmsg.notification?.android?.tag,
|
||||
this.notificationAppleBadge = rmsg.notification?.apple?.badge,
|
||||
this.notificationAppleSound = rmsg.notification?.apple?.sound,
|
||||
this.notificationAppleSound = rmsg.notification?.apple?.sound?.toString(),
|
||||
this.notificationAppleImageUrl = rmsg.notification?.apple?.imageUrl,
|
||||
this.notificationAppleSubtitle = rmsg.notification?.apple?.subtitle,
|
||||
this.notificationAppleSubtitleLocArgs = rmsg.notification?.apple?.subtitleLocArgs,
|
||||
@@ -195,12 +191,11 @@ class FBMessage extends HiveObject implements FieldDebuggable {
|
||||
('category', this.category ?? ''),
|
||||
('collapseKey', this.collapseKey ?? ''),
|
||||
('contentAvailable', this.contentAvailable.toString()),
|
||||
('data', this.data.toString()),
|
||||
('data', this.data.entries.map((e) => '${e.key} := ${e.value}').join('\n')),
|
||||
('from', this.from ?? ''),
|
||||
('messageId', this.messageId ?? ''),
|
||||
('messageType', this.messageType ?? ''),
|
||||
('mutableContent', this.mutableContent.toString()),
|
||||
('notification', this.notification?.toString() ?? ''),
|
||||
('sentTime', this.sentTime?.toString() ?? ''),
|
||||
('threadId', this.threadId ?? ''),
|
||||
('ttl', this.ttl?.toString() ?? ''),
|
||||
|
@@ -26,7 +26,6 @@ class FBMessageAdapter extends TypeAdapter<FBMessage> {
|
||||
messageId: fields[6] as String?,
|
||||
messageType: fields[7] as String?,
|
||||
mutableContent: fields[8] as bool,
|
||||
notification: fields[9] as RemoteNotification?,
|
||||
sentTime: fields[10] as DateTime?,
|
||||
threadId: fields[11] as String?,
|
||||
ttl: fields[12] as int?,
|
||||
@@ -36,15 +35,14 @@ class FBMessageAdapter extends TypeAdapter<FBMessage> {
|
||||
notificationAndroidCount: fields[23] as int?,
|
||||
notificationAndroidImageUrl: fields[24] as String?,
|
||||
notificationAndroidLink: fields[25] as String?,
|
||||
notificationAndroidPriority: fields[26] as AndroidNotificationPriority?,
|
||||
notificationAndroidPriority: fields[26] as String?,
|
||||
notificationAndroidSmallIcon: fields[27] as String?,
|
||||
notificationAndroidSound: fields[28] as String?,
|
||||
notificationAndroidTicker: fields[29] as String?,
|
||||
notificationAndroidVisibility:
|
||||
fields[30] as AndroidNotificationVisibility?,
|
||||
notificationAndroidVisibility: fields[30] as String?,
|
||||
notificationAndroidTag: fields[31] as String?,
|
||||
notificationAppleBadge: fields[40] as String?,
|
||||
notificationAppleSound: fields[41] as AppleNotificationSound?,
|
||||
notificationAppleSound: fields[41] as String?,
|
||||
notificationAppleImageUrl: fields[42] as String?,
|
||||
notificationAppleSubtitle: fields[43] as String?,
|
||||
notificationAppleSubtitleLocArgs: (fields[44] as List?)?.cast<String>(),
|
||||
@@ -64,7 +62,7 @@ class FBMessageAdapter extends TypeAdapter<FBMessage> {
|
||||
@override
|
||||
void write(BinaryWriter writer, FBMessage obj) {
|
||||
writer
|
||||
..writeByte(40)
|
||||
..writeByte(39)
|
||||
..writeByte(0)
|
||||
..write(obj.senderId)
|
||||
..writeByte(1)
|
||||
@@ -83,8 +81,6 @@ class FBMessageAdapter extends TypeAdapter<FBMessage> {
|
||||
..write(obj.messageType)
|
||||
..writeByte(8)
|
||||
..write(obj.mutableContent)
|
||||
..writeByte(9)
|
||||
..write(obj.notification)
|
||||
..writeByte(10)
|
||||
..write(obj.sentTime)
|
||||
..writeByte(11)
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
@@ -13,6 +14,8 @@ class Globals {
|
||||
|
||||
Globals._internal();
|
||||
|
||||
bool _initialized = false;
|
||||
|
||||
String appName = '';
|
||||
String packageName = '';
|
||||
String version = '';
|
||||
@@ -24,7 +27,11 @@ class Globals {
|
||||
|
||||
late SharedPreferences sharedPrefs;
|
||||
|
||||
bool get isInitialized => _initialized;
|
||||
|
||||
Future<void> init() async {
|
||||
if (_initialized) return;
|
||||
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
this.appName = packageInfo.appName;
|
||||
@@ -54,6 +61,8 @@ class Globals {
|
||||
}
|
||||
|
||||
this.sharedPrefs = await SharedPreferences.getInstance();
|
||||
|
||||
this._initialized = true;
|
||||
}
|
||||
|
||||
String? getPrefFCMToken() {
|
||||
|
Reference in New Issue
Block a user