I'm developing an app in React Native and wanted to receive notifications in the app using Onesignal and Firebase, but I'm getting an error, I've already looked in the documentation and apparently it's correct to use.
follows the error code:
useEffect(()=>{
OneSignal.init("7c7b85c7-3bd2-48e3-8c75-02835cb223c8");
OneSignal.addEventListener('opened', this.onOpened);
return () => OneSignal.removeEventListener('opened', this.onOpened);
}, []);
function onOpened(openResult){
console.log('Message: ', openResult.notification.payload.body);
console.log('openResult: ', openResult);
}
Error:
TypeError: react_native_onesignal__WEBPACK_IMPORTED_MODULE_4__.default.init is not a function
(anonymous function)
C:/Projeto/AppText/App.js:11
8 |
9 | useEffect(()=>{
10 |
> 11 | OneSignal.init("7c7b85c7-3bd2-48e3-8c75-02835cb223c8");
12 | ^
13 | OneSignal.addEventListener('opened', this.onOpened);
14 |