Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]: Missing addObserver function #933

Closed
1 task done
xylish7 opened this issue Oct 20, 2023 · 2 comments
Closed
1 task done

[question]: Missing addObserver function #933

xylish7 opened this issue Oct 20, 2023 · 2 comments

Comments

@xylish7
Copy link

xylish7 commented Oct 20, 2023

How can we help?

In docs it is mentioned that if you want to listen for push subscription changes, addObserver listener should be used.

image

However it looks like there is no addObserver function so I'm not sure how I can listen to notification changes.

image

Thank you!

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nan-li
Copy link
Contributor

nan-li commented Oct 23, 2023

Hi @xylish7,

Thank you for reporting this issue with our documentation, that we will fix.

The most updated listing of available methods is available in the migration guide here.

The correct method is addEventListener("change", listener) with this example:

    const listener = (event: PushSubscriptionChangedState) => {
        console.log("Push subscription changed: " + (event));
    };
    OneSignal.User.pushSubscription.addEventListener("change", listener);
    // Remove the listener
    OneSignal.User.pushSubscription.removeEventListener("change", listener);

I apologize for the confusion and will update our docs.

@nan-li nan-li closed this as completed Oct 23, 2023
@xylish7
Copy link
Author

xylish7 commented Oct 24, 2023

I see and no problem😊. Will try with OneSignal.User.pushSubscription.addEventListener("change", listener); . Thank you for your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants