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

Can't find any documentation on how to handle the actions buttons in my notification #1684

Open
1 task done
sleekLancelot opened this issue Apr 9, 2024 · 2 comments
Open
1 task done

Comments

@sleekLancelot
Copy link

How can we help?

I need some help on how to handle action buttons, they are already been sent from the server, i just need to lead the user to a screen in the app when the button is clicked.

I can see a "How can I use the action button click event?" Section in the docs. But the only part of that section that seems useful to my use-case leads to "page not found".
https://documentation.onesignal.com/docs/web-push-sdk#addlistenerfornotificationopened

Code of Conduct

  • I agree to follow this project's Code of Conduct
@VirtualDOMinic
Copy link

Not got all the answers for you as I don't work for OneSignal, but:

The broken link will work if you change the URL to v9 (their previous version) https://documentation.onesignal.com/v9.0/docs/web-push-sdk#addlistenerfornotificationopened . If you're using the latest, this may obviously not be what you want. Note that it's a page for the web SDK though.

There's a similar page in the old docs here too https://documentation.onesignal.com/v9.0/docs/action-buttons#how-can-i-use-the-action-button-to-do-some-work-on-my-page-without-opening-extra-windows

If you're using the latest version of RN OneSignal, though, I'm pretty sure you can do the following:

OneSignal.Notifications.addEventListener('click', event => {
  // check the actionId of the notification button that you set via: `event.result.actionId`
  // Now you have access to the actionId and can redirect (navigate) accordingly

@sleekLancelot
Copy link
Author

sleekLancelot commented Apr 20, 2024

Thanks a lot for helping @VirtualDOMinic, i was able to get it to work by reading the docs of other SDK's and even older ones like the one you shared too.
Thanks man!

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