Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question]: Does this work in ExpoGo? #211

Closed
1 task done
PolyPlugins opened this issue Nov 15, 2023 · 4 comments
Closed
1 task done

[question]: Does this work in ExpoGo? #211

PolyPlugins opened this issue Nov 15, 2023 · 4 comments
Labels

Comments

@PolyPlugins
Copy link

PolyPlugins commented Nov 15, 2023

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

  • I agree to follow this project's Code of Conduct
@rgomezp
Copy link
Contributor

rgomezp commented Nov 16, 2023

It does not work with Expo Go. Please see this repo's README for supported environments

@rgomezp rgomezp closed this as completed Nov 16, 2023
@PolyPlugins
Copy link
Author

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.

@PolyPlugins
Copy link
Author

PolyPlugins commented Nov 17, 2023

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.

@newme616
Copy link

newme616 commented Jan 4, 2024

@PolyPlugins thx so much! this should be updatet in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants