We have released an update for android, and have seen errors appearing in users.
The app does not crash. But the error is fixed in the play market.
I was able to reproduce the error on the emulator. You need to enable "hot reload" and update the App.js.


App.js
class App extends Component<Props> {
constructor(props) {
super(props);
OneSignal.init("*********");
OneSignal.addEventListener('received', this.onReceived);
OneSignal.addEventListener('opened', this.onOpened);
OneSignal.addEventListener('ids', this.onIds);
this.state = {
}
}
componentWillUnmount() {
OneSignal.removeEventListener('received ', this.onReceived);
OneSignal.removeEventListener('opened', this.onOpened);
OneSignal.removeEventListener('ids', this.onIds);
}
}
if I comment on this line, the error disappears.
OneSignal.removeEventListener('received ', this.onReceived);
"react-native-onesignal": "^3.4.2
"react-native": "0.61.5"
"react": "16.9.0"
+
The problem also occurs when the application is minimized, using the Back Handler.exitApp();
You're on an old version of the SDK. Please update
I deleted the node modules folder and updated one signal to version 3.5.0, but the app crashes as well.
It seems to me that the problem is in this place.
OneSignal.removeEventListener('received ', this.onReceived);
Howdy, this is a very strange error. You can see the source code here. The received event is clearly defined.
I still don't understand why it arises. It appeared after the update of react and react-native .
Will there be a memory leak if I remove this line. As a temporary solution?
Not really sure. Doesn't hurt to try.
I would recommend trying to reproduce this in our example app or in a fresh new project
FYI, in case you didn't figure it out, your event listener has a space after the word received. Change:
OneSignal.removeEventListener('received ', this.onReceived);
to
OneSignal.removeEventListener('received', this.onReceived);
Good catch @district-michael , thanks for contributing!
FYI, in case you didn't figure it out, your event listener has a space after the word received. Change:
OneSignal.removeEventListener('received ', this.onReceived);
to
OneSignal.removeEventListener('received', this.onReceived);
Yeah, I just didn't see it. Thanks for the answer.
Most helpful comment
FYI, in case you didn't figure it out, your event listener has a space after the word received. Change:
OneSignal.removeEventListener('received ', this.onReceived);to
OneSignal.removeEventListener('received', this.onReceived);