react-native-onesignal icon indicating copy to clipboard operation
react-native-onesignal copied to clipboard

Cannot read property 'configure' of undefined

Open indie314 opened this issue 9 years ago • 9 comments

"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?

indie314 avatar Mar 06 '17 14:03 indie314

I am having the exact same problem

Quirksmode avatar Mar 11 '17 13:03 Quirksmode

Same issue here. Mine throws the error here: https://github.com/geektimecoil/react-native-onesignal/blob/master/index.js#L24

yudori avatar Mar 14 '17 11:03 yudori

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.

kuby avatar Mar 22 '17 12:03 kuby

Hi, the same here. Anyone has solution?

cuongv avatar Mar 25 '17 09:03 cuongv

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.

kuby avatar Mar 25 '17 11:03 kuby

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

balajmarius avatar Mar 30 '17 08:03 balajmarius

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 avatar Mar 30 '17 08:03 cuongv

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

balajmarius avatar Mar 30 '17 08:03 balajmarius

@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:

  • Make sure that you have the same changes that described in https://github.com/geektimecoil/react-native-onesignal#android-installation
  • See example project's MainApplication file and diff it with file in your project. ReactNativeOneSignalPackage must be initialized to be available from JS

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

arkhwise avatar Apr 19 '17 13:04 arkhwise