🐛 Fix some issues on Android and Web

This commit is contained in:
2025-03-23 16:24:53 +08:00
parent 21a1d4a2ad
commit 8dd6435a30
10 changed files with 174 additions and 167 deletions

View File

@ -48,13 +48,11 @@ class NotificationProvider extends ChangeNotifier {
var deviceUuid = await FlutterUdid.consistentUdid;
if (deviceUuid.isEmpty) {
logging.warning(
'[Push Notification] Unable to active push notifications, couldn\'t get device uuid');
logging.warning('[Push Notification] Unable to active push notifications, couldn\'t get device uuid');
return;
} else {
logging.info('[Push Notification] Device UUID is $deviceUuid');
logging
.info('[Push Notification] Registering device push notifications...');
logging.info('[Push Notification] Registering device push notifications...');
}
if (Platform.isIOS || Platform.isMacOS) {
@ -66,14 +64,14 @@ class NotificationProvider extends ChangeNotifier {
}
logging.info('[Push Notification] Device Push Token is $token');
await _sn.client.post(
'/cgi/id/notifications/subscription',
data: {
'provider': provider,
'device_token': token,
'device_id': deviceUuid,
},
);
try {
await _sn.client.post(
'/cgi/id/notifications/subscription',
data: {'provider': provider, 'device_token': token, 'device_id': deviceUuid},
);
} catch (err) {
logging.error('[Push Notification] Unable to register push notifications: $err');
}
}
int showingCount = 0;
@ -91,8 +89,7 @@ class NotificationProvider extends ChangeNotifier {
final doHaptic = _cfg.prefs.getBool(kAppNotifyWithHaptic) ?? true;
if (doHaptic) HapticFeedback.mediumImpact();
if (notification.topic == 'messaging.message' &&
skippableNotifyChannel != null) {
if (notification.topic == 'messaging.message' && skippableNotifyChannel != null) {
if (notification.metadata['channel_id'] != null &&
notification.metadata['channel_id'] == skippableNotifyChannel) {
return;