add timeout for UP reg
This commit is contained in:
parent
02ba9180db
commit
61c5aa94c2
1 changed files with 6 additions and 0 deletions
|
|
@ -55,6 +55,9 @@ class UnifiedPushController extends AsyncNotifier<bool> {
|
||||||
|
|
||||||
state = .data(true);
|
state = .data(true);
|
||||||
},
|
},
|
||||||
|
onRegistrationFailed: (reason, instance) {
|
||||||
|
throw reason;
|
||||||
|
},
|
||||||
onMessage: (message, instance) async {
|
onMessage: (message, instance) async {
|
||||||
debugPrint("UP message received for $instance");
|
debugPrint("UP message received for $instance");
|
||||||
if (message.decrypted == false) {
|
if (message.decrypted == false) {
|
||||||
|
|
@ -146,6 +149,9 @@ class UnifiedPushController extends AsyncNotifier<bool> {
|
||||||
await UnifiedPush.register(
|
await UnifiedPush.register(
|
||||||
instance: deviceId,
|
instance: deviceId,
|
||||||
vapid: capabilities.webpush?.vapid,
|
vapid: capabilities.webpush?.vapid,
|
||||||
|
).timeout(
|
||||||
|
.new(seconds: 15),
|
||||||
|
onTimeout: () => throw Exception("UnifiedPush registration timed out."),
|
||||||
);
|
);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
state = .data(false);
|
state = .data(false);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue