forked from Nexus/nexus
pass pushes to gomuks
This commit is contained in:
parent
adf3da8d77
commit
02704e97ef
4 changed files with 33 additions and 17 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import "dart:convert";
|
||||
import "dart:io";
|
||||
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
|
|
@ -12,6 +13,7 @@ import "package:unifiedpush_storage_shared_preferences/storage.dart";
|
|||
class UnifiedPushController extends AsyncNotifier<bool> {
|
||||
@override
|
||||
Future<bool> build() async {
|
||||
final client = ref.watch(ClientController.provider.notifier);
|
||||
final registered = await UnifiedPush.initialize(
|
||||
linuxOptions: .new(
|
||||
dbusName: "nexus.federated.nexus.UnifiedPush",
|
||||
|
|
@ -19,7 +21,6 @@ class UnifiedPushController extends AsyncNotifier<bool> {
|
|||
background: isInBackground,
|
||||
),
|
||||
onNewEndpoint: (endpoint, instance) async {
|
||||
final client = ref.watch(ClientController.provider.notifier);
|
||||
await client.registerPusher(
|
||||
.new(
|
||||
appDisplayName: "Nexus",
|
||||
|
|
@ -37,16 +38,16 @@ class UnifiedPushController extends AsyncNotifier<bool> {
|
|||
);
|
||||
},
|
||||
onMessage: (message, instance) async {
|
||||
print(message);
|
||||
// TODO: Handle incoming message
|
||||
final e = await client.handlePush(
|
||||
json.decode(String.fromCharCodes(message.content)),
|
||||
);
|
||||
print(e);
|
||||
},
|
||||
onRegistrationFailed: (e, r) {
|
||||
throw "e";
|
||||
},
|
||||
onUnregistered: (_) {
|
||||
throw "r";
|
||||
},
|
||||
onTempUnavailable: (_) {
|
||||
onUnregistered: (instance) => ref.invalidateSelf(),
|
||||
onTempUnavailable: (instance) {
|
||||
throw "t";
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue