diff --git a/lib/utils/background_push.dart b/lib/utils/background_push.dart index 4469c0166..f53ccb7af 100644 --- a/lib/utils/background_push.dart +++ b/lib/utils/background_push.dart @@ -94,7 +94,7 @@ class BackgroundPush { if (Platform.isAndroid) { await UnifiedPush.initialize( onNewEndpoint: _newUpEndpoint, - onRegistrationFailed: _upUnregistered, + onRegistrationFailed: (_, reason) => _upUnregistered(reason), onUnregistered: _upUnregistered, onMessage: _onUpMessage, ); @@ -352,7 +352,8 @@ class BackgroundPush { .registerAppWithDialog(); } - Future _newUpEndpoint(String newEndpoint, String i) async { + Future _newUpEndpoint(PushEndpoint pushEndpoint, String i) async { + final newEndpoint = pushEndpoint.url; upAction = true; if (newEndpoint.isEmpty) { await _upUnregistered(i); @@ -397,9 +398,9 @@ class BackgroundPush { await matrix?.store.setBool(SettingKeys.unifiedPushRegistered, true); } - Future _upUnregistered(String i) async { + Future _upUnregistered(String reason) async { upAction = true; - Logs().i('[Push] Removing UnifiedPush endpoint...'); + Logs().i('[Push] Removing UnifiedPush endpoint...', reason); final oldEndpoint = matrix?.store.getString(SettingKeys.unifiedPushEndpoint); await matrix?.store.setBool(SettingKeys.unifiedPushRegistered, false); @@ -412,10 +413,10 @@ class BackgroundPush { } } - Future _onUpMessage(Uint8List message, String i) async { + Future _onUpMessage(PushMessage message, String i) async { upAction = true; final data = Map.from( - json.decode(utf8.decode(message))['notification'], + json.decode(utf8.decode(message.content))['notification'], ); // UP may strip the devices list data['devices'] ??= []; @@ -446,7 +447,7 @@ class UPFunctions extends UnifiedPushFunctions { @override Future registerApp(String instance) async { - await UnifiedPush.registerApp(instance, features); + await UnifiedPush.register(instance: instance, features: features); } @override diff --git a/pubspec.lock b/pubspec.lock index 3567b97bb..3f8ff8c16 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -2021,26 +2021,26 @@ packages: dependency: "direct main" description: name: unifiedpush - sha256: "6dbed5a6305ca33f1865c7a3d814ae39476b79a2d23ca76a5708f023f405730f" + sha256: "1418375efb580af9640de4eaf4209cb6481f9a48792648ced3051f30e67d9568" url: "https://pub.dev" source: hosted - version: "5.0.2" + version: "6.0.2" unifiedpush_android: dependency: transitive description: name: unifiedpush_android - sha256: "7443dece0a850ae956514f809983eb2b39fc518c2c7d24dbfe817198bec89134" + sha256: "2f25db8eb2fc3183bf2e43db89fff20b2587adc1c361e1d1e06b223a0d45b50a" url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "3.1.1" unifiedpush_platform_interface: dependency: transitive description: name: unifiedpush_platform_interface - sha256: dd588d78a8b2bfc10430e30035526e98caa543d0b7364a6344b5eb4815721c6d + sha256: bb49d2748211520e35e0374ab816faa8a2c635267e71909d334ad868d532eba5 url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "3.0.1" unifiedpush_ui: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index ee092c7b6..a6db2520f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -85,7 +85,7 @@ dependencies: sqlcipher_flutter_libs: ^0.6.1 swipe_to_action: ^0.3.0 tor_detector_web: ^1.1.0 - unifiedpush: ^5.0.1 + unifiedpush: ^6.0.2 unifiedpush_ui: ^0.1.0 universal_html: ^2.2.4 url_launcher: ^6.2.5