Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

javascript - How I need to solve error ini one signal react native

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I already solved this issues, its turn out One Signal changed their method with the new vesion. So the function already different now. Thanks all.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...