This is my code, I am using hooks and also already try with class component too, but I faced some error
useEffect(() => {
OneSignal.setLogLevel(6, 0);
OneSignal.init('a6a1f13d-8823-4d98-86c9-d99aef433795', {
kOSSettingsKeyAutoPrompt: false,
kOSSettingsKeyInAppLaunchURL: false,
kOSSettingsKeyInFocusDisplayOption: 2,
});
OneSignal.inFocusDisplaying(2);
OneSignal.addEventListener('received', onReceived);
OneSignal.addEventListener('opened', onOpened);
OneSignal.addEventListener('ids', onIds);
return () => {
OneSignal.removeEventListener('received', onReceived);
OneSignal.removeEventListener('opened', onOpened);
OneSignal.removeEventListener('ids', onIds);
}}, []);
const onReceived = (notification) => {
console.log('Notification received: ', notification);}
const onOpened = (openResult) => {
console.log('Message: ', openResult.notification.payload.body);
console.log('Data: ', openResult.notification.payload.additionalData);
console.log('isActive: ', openResult.notification.isAppInFocus);
console.log('openResult: ', openResult)}
const onIds = (device) => {
console.log('Device info: ', device)}
TypeError: _reactNativeOnesignal.default.init is not a function. (In '_reactNativeOnesignal.default.init('a6a1f13d-8823-4d98-86c9-d99aef433795')', '_reactNativeOnesignal.default.init' is undefined)
question from:
https://stackoverflow.com/questions/65644403/how-i-need-to-solve-error-ini-one-signal-react-native 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…