Closed PolyPlugins closed 7 months ago
It does not work with Expo Go. Please see this repo's README for supported environments
It does not work with Expo Go. Please see this repo's README for supported environments
It also triggers the same error on npx expo run:android which shows supported. It does still seem to run in ExpoGo on the emulator though after running run:android, so is there another step you need to do to get it to work? We can compile an APK, but if there is a faster and easier method of debugging that would be very helpful.
To anyone else having trouble with the "Cannot read property 'initialize' of undefined", it's because we used the example plugin and it's very out of date. With the current version you import it as import { OneSignal } from 'react-native-onesignal';
Not import OneSignal from 'react-native-onesignal';
We were trying to find a better example of usage, because the documentation didn't specify how to prompt users to enable notifications, however OneSignal has changed how this happens using in app messaging (which is actually pretty cool and has many other use cases) https://documentation.onesignal.com/docs/how-to-prompt-for-push-permissions-with-an-in-app-message
So you really do just need the initialize function. I suggest you read OneSignal's documentation as it's a bit more detailed: https://documentation.onesignal.com/docs/react-native-expo-sdk-setup
Once we made the change, npx expo run:android worked perfectly.
@PolyPlugins thx so much! this should be updatet in the docs
How can we help?
When trying to initialize, we're getting "Cannot read property 'initialize' of undefined" We log OneSignal and it returns null. We tried to npx expo run:android and the same thing is happening.
OneSignal Expo SDK version
"onesignal-expo-plugin": "^2.0.2", "react-native-onesignal": "5.0.2",
Platform
Android
Relevant log output
No response
Code of Conduct