react-native-onesignal
react-native-onesignal copied to clipboard
Can't find any documentation on how to handle the actions buttons in my notification
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
- [X] I agree to follow this project's Code of Conduct
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
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!
Thank you for your help here, @VirtualDOMinic!