Solved

React native integration

  • 2 February 2022
  • 3 replies
  • 742 views

Badge

I have used Amplitude integrated with react native and expo for a few months for my mobile application, everything was working fine.

I was using the package “expo-analytics-amplitude”. Recently, I have developed a web version. The latest package does not work for web (cf https://docs.expo.dev/versions/latest/sdk/amplitude/). Apparently, there won’t be a web version and this package will be deprecated soon (cf https://github.com/expo/expo/issues/6886#issuecomment-1015957268) in favor of https://www.npmjs.com/package/@amplitude/react-native

 

Trying to implement amplitude/react-native, I ran into the following issue:

https://github.com/amplitude/Amplitude-ReactNative/issues/96

for which there does not seem to be any fix nor workaround.

 

Any solution except switching to mixpanel?

 

Thanks

 

icon

Best answer by Denis Holmes 8 February 2022, 18:16

View original

3 replies

Userlevel 6
Badge +8

Hi @GillesN ,

 

Thanks for writing into Amplitude Community! All Starters now write in here and it is great to see it being used more! :D 

I understand you are having issues with the React Native SDK library from Amplitude. Can you make sure you do not have any VPNs or Active? Can you ensure there is no 3rd party interference with the internet connection too. I have come across this before and as someone posted, it is often helps to re-install the application using react-native run-android after npm install @amplitude/react-native@latest.

Can you check if that helps? If not, can you remove the React-Native SDK and try to reinstall it again and see if that helps?

 

I hope this helps for now! I look forward to your reply so we can proceed!

 

Kind Regards,
Denis

Badge

Hello @Denis,

 

Thanks for your answer.

 

There is no active VPN. Not really sure what you mean with third party interference but as far as I know, there is not. I reinstalled @amplitude/react-native and react-native but the error remains.

 

Thanks,

Gilles

Userlevel 6
Badge +8

To close the loop here, this was an issue with Expo.

 

We do know Expo can cause issues with this. So first of all, using Expo inherently imposes limits on what type of react-native libraries you can use. Checkout: Using libraries - Expo Documentation

Now check the following:
Does it include an ios and/or android directory? (our library does)
Does the README mention linking?
Is it built specifically for Node.js, the web, electron, or another platform?

If you answered yes to either of these questions and the library is not part of the Expo SDK, this library may not be supported in the managed workflow! Run expo init and add the library to the new project and try to use it. This is a great way to experiment with a library before including it in your project in all circumstances.

If the library is not compatible with the managed workflow and you need it to build your app, you may want to eject to the bare workflow. We do not support Expo because of the restraints listed above. You can either eject from expo or use the react-native-cli.
To create an app from react-native-cli:
npx react-native init AwesomeProject
More details here: Setting up the development environment · React Native
Here Using libraries - Expo Documentation , you will see that libraries with ios/android folders are rarely supported by expo’s Managed workflow. We built this library for react-native-cli users.
Expo does have their own module for Amplitude: Amplitude - Expo Documentation
Bottom line, official sdk is not usable in expo.

Reply