watchPosition fails with react native expo - android

Hi I'm beginner in React Native, and I used react-native-create-app to generate a react native app.
I'm using navigator.geolocation.watchPosition(...) in it
Exactly as in the example here https://facebook.github.io/react-native/releases/0.24/docs/geolocation.html
(I ejected in order to add geolocation permission in AndroidManifest.xml as described)
When I npm start, and scan the QR code given by Expo, I have the following error
error screenshot
However, when I'm running the app with react-native run-android instead, it's working well.
But I would like to continue to use Expo, somebody had already encounter this issue or someone see a way to solve it ? Thanks !

Related

react-native-google-mobile-ads with Expo managed workflow will not work

I have followed all of the most up-to-date guides and suggestions for getting react-native-google-mobile-ads to work with an Expo managed workflow, including these:
How to use react-native-google-mobile-ads with Expo?
How do I use react-native-google-mobile-ads with Expo and Expo Go?
But I keep getting the same error:
ERROR TypeError: null is not an object (evaluating 'RNAppModule.eventsNotifyReady')
It would seem that this error originates in this jest.setup.ts file:
https://github.com/invertase/react-native-google-mobile-ads/blob/main/jest.setup.ts
but I have no idea what the error is or how to overcome it.
This error happens when I initiate interstitial.load() as per the official documentation.
Any help would be greatly appreciated.
Ran into this same problem. Turns out the command to use was hidden in their docs at the end of the build steps without any explanation.
https://docs.page/invertase/react-native-google-mobile-ads#setting-up-google-admob
Using react-native-google-mobile-ads, Expo Go will no longer be able to handle linking all the native dependencies. So you'll have to use EAS to build it. Per the docs, you can use npx eas-cli build --profile development to build for development. Alternatively, to install locally rather than on EAS servers, add the --local flag to that command. Just note that if building locally you may need to set the Android SDK path following the instructions to edit your eas.json at Expo build EAS - local - SDK location not found.
After building for Android (I don't have a Mac so I can't speak for development on iOS), it generates an apk which you need to install on your device. I'm sure there's a way to install this on an emulator too.
Once you've opened that app, it will direct you to start a development server using expo start --dev-client. This will run a dev server similar to the usual Expo Go. It pulls up a QR code which you can scan and it will take you into your app. Hot reload works as expected too. Doing this my test banner ad showed up without any errors.
The same solution is discussed here.

React Native: Expo run project on android device

I'm trying to run my react native project on an android device using expo, and this error page shows up. There are multiple similar questions regarding this, but they're all either outdated or they simply don't work. Anyone got any ideas?. Thanks in advance

React native not picking up android changes

Just a general question I couldn't quite find an answer for.
I've been developing a react native app and noticed that when I run it on android it works fine. But when I build and run it on ios it doesn't pick up some of my css changes or some features aren't working as expected.
Is there a reason for this or am I missing like some universal package for react-native?
Try running react-native run-ios in the command line

Problem after linking Firebase to a React Native app

I am trying to link my react-native app to firebase and work on the auth module.
I followed the steps of the installation in https://rnfirebase.io/
It works when I run npx react-native run-android
But when I use expo start to work on the pre-production app I always get the error you attempted to use a firebase module that is not installed firebase.app()
After working on this problem for while, after solving it, I would like to share my answer.
The library https://rnfirebase.io/ does not work with a managed workflow like Expo, so be sure to use the bare workflow to work with the library.

React Native Eject but still being able to use React Native code

I've built some little prototypes within Expo with React Native but now I'm in the middle of a real project and I'm now discovering I will definitely need to eject my project for certain components to work.
My question is, once I eject, can I ever write React Native Code without having to init again which I assume will erase any changes I made at the native level?
Any techniques or references are appreciated.
Your question is a bit confusing, so I'll try to answer it as best as I can.
TL;DR: You will be able to write React Native code once you eject from Expo without having to use expo-cli init.
Expo Init
When you say "...can I ever write React Native Code without having to init again..." I assume you mean exp init (or expo-cli init) as opposed to react-native init. These commands merely initialize the project for you, so you shouldn't need to run them more than once.
For more information about how they differ from one another I recommend this GitHub issue thread.
Expo Eject
Expo allows you to eject your pure-JS project from the Expo iOS/Android clients, providing you with native projects that can be opened and built with Xcode and Android Studio. Those projects will have dependencies on ExpoKit, so everything you already built will keep working as it did before.
This means that when you eject your app you'll be writing React Native code outside of the Expo client environment, meaning you'll have access to the native code for Android and iOS. Even so, you will write normal React Native code (Javascript and JSX).
Also once you eject, Expo will add Expo Kit to your project which will give you access to some of Expo's features. For more information check their docs.

Categories

Resources