PushManager.getSubscription() errors on null
mrwonko opened this issue · comments
PushManager.getSubscription
is defined as Future<PushSubscription>
, but if there's no subscription, it actually returns null
, leading to an Error:
Error: Expected a value of type 'FutureOr', but got one of type 'Null'
According to https://developer.mozilla.org/en-US/docs/Web/API/PushManager/getSubscription, this is expected, and I don't see how else I'd check whether a subscription has been configured yet.
Can be reproduced with
await (await html.window.navigator.serviceWorker?.ready)?.pushManager?.getSubscription();