Skip to content

PushManager.getSubscription() errors on null #1081

Open
@mrwonko

Description

@mrwonko

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();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions