Show dynamic notification
harryharihar opened this issue · comments
Harihar Khobragade commented
I am new to react native , i have integrated one signal for push notification in my application and now i need to show notification when notification fired.
this is my notification function
onReceived(notification) {
console.log("Notification received: ", notification);
}
whenever i call this.popup.show() its shows me error
Carson Wah commented
Hi @harryharihar , thanks for trying out this package.
Are you passing onReceived
as a callback function in component render()
?
If so, you may need to bind this or use arrow function.
E.g.
export default class App extends Component {
constructor() {
OneSignal.addEventListener('received', this.onReceived.bind(this)); // HERE
}
onReceived(notification) {
console.log("Notification received: ", notification);
this.popup.show({});
}
}
or
export default class App extends Component {
constructor() {
OneSignal.addEventListener('received', this.onReceived);
}
onReceived = (notification) => { // HERE
console.log("Notification received: ", notification);
this.popup.show({});
}
}
If this does not solve your problem, please provide an error log.