Closed daniimd closed 1 week ago
Hi @daniimd From the error message, it seems OneSignal is not yet initialized before the call to add event listerner.
Furthermore, if this is your code
OneSignal.Notifications.addEventListener((event) => {
console.log('OneSignal: notification clicked:', event);
})
then the other issue is that you are not specifying the event you are adding listener for. Take a look at the examples below for notification click event;
OneSignal.Notifications.addEventListener("click", (event) => {
console.log('OneSignal: notification clicked:', event);
})
to get and display the notification on click, you can do this;
OneSignal.Notifications.addEventListener("click", (event) => {
console.log('OneSignal: notification clicked:', event);
const notification = event.notification;
if (notification === undefined) { return; }
Alert.alert(notification.title, notification.body); // You need to import Alert from react-native
})
I hope this helps
Thanks @opmat ,
Closing due to inactivity from OP
What happened?
When sending a
PUSH
through onesignal, I receive the notification normally, but when clicking on it I cannot get any action, I tried usingaddEventListener
, but an error is returnedCode:
Error:![image](https://github.com/OneSignal/onesignal-expo-plugin/assets/36265891/6eb8ff9b-b166-44b3-be8c-5f4a38a45f6f)
Version:
Steps to reproduce?
What did you expect to happen?
I hope some function returns an action for tapping the notification
OneSignal Expo SDK version
49.0.6
Platform
Android
Relevant log output
No response
Code of Conduct