React-native-onesignal: Cannot read property 'configure' of undefined

Created on 6 Mar 2017  路  9Comments  路  Source: OneSignal/react-native-onesignal

"TypeError: Cannot read property 'configure' of undefined
    at Function.configure (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:68053:12)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:67958:33
    at tryCallOne (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:26338:8)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:26424:9
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:8797:49
    at Object.callTimer (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7706:1)
    at Object.callImmediatesPass (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7810:19)
    at Object.callImmediates (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7825:25)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7512:43
    at guard (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:7344:1)"

Hello, I'am using react-native 0.40 and react-native-onesignal 3.0.3 with Android, after I did all the setup I import the onesignal library and try to get the id, but I get the error above.

import OneSignal from 'react-native-onesignal'
OneSignal.addEventListener('ids', device => console.log(device))

Does anyone else had this problem?
I am doing something wrong?

Most helpful comment

@indie314 @Quirksmode @yudori @kuby @cuongv

I had the same with RN versions 0.40 and 0.42.
react-native link react-native-onesignal command didn't update my MainApplication.java

This solution for Android:

If you don't know why you should initialize modules in getPackages method, I recommend you to see https://facebook.github.io/react-native/docs/native-modules-android.html

All 9 comments

I am having the exact same problem

Anybody with a solution? I am having the same problem.
When I launch my app first after build (with react-native run-android), it works fine, without error and also receiving notifications, but after I exit my app (with force exit, just remove it from running apps) and then I launch the app again, this error appears and the notifications are not working anymore.

Hi, the same here. Anyone has solution?

So in my case, it was really weird problem and I have no idea how was that even possible, but I had installed my app 2 times on my device, and that coused the problem. I figured this out when I built a signed APK, and when I tried to install it, there was an message that said "you have another version installed already". So then I removed all versions of the app from my device and installed it again and it worked without problem. (Works also with debug version and a release version too)

Maybe it is not related, but I also downgraded my react-native-onesignal version to 3.0.2 couse of another iOS related problem I needed to fix.

I had the same problem on Android, it was because react-native-onesignal was not linked 馃槵馃敨.
I just run the following command and worked.

react-native link react-native-onesignal

I did have react-native-onesignal linked. Still not work. Anyway, quit react native and back to swift after few months of miserable. ha ha.

@cuongv maybe try to install it on a fresh project, react-native worked really well on my side

@indie314 @Quirksmode @yudori @kuby @cuongv

I had the same with RN versions 0.40 and 0.42.
react-native link react-native-onesignal command didn't update my MainApplication.java

This solution for Android:

If you don't know why you should initialize modules in getPackages method, I recommend you to see https://facebook.github.io/react-native/docs/native-modules-android.html

Was this page helpful?
0 / 5 - 0 ratings