SudoPlz / sp-react-native-in-app-updates

An in-app updater for the native version of your react-native app.
MIT License
491 stars 66 forks source link

Not working with Expo #3

Closed rahul-budhia closed 4 years ago

rahul-budhia commented 4 years ago

Hi, I am trying to use this in my expo app. I am assuming native linking doesn't work for it right now with expo. I get the following error. Is there any plan to make it work with expo? \ \ inappupdate

Thanks

SudoPlz commented 4 years ago

Hey there @rahul-budhia - we're not using expo at all, but if the project is exported it should work since it's just another react-native project.

I'm not super familiar with expo myself, but if I'm missing something and extra steps are needed for it to work with expo, a PR would be super welcome!

Gustash commented 4 years ago

@rahul-budhia Expo only works with native packages that Expo themselves bundle in, you might have some luck with ExpoKit, but I've personally never tried it.

a-eid commented 2 years ago

@gustash that is not the case anymore with expo custom dev clients and expo plugins. you can create a plugin for any native package to work with an expo custom dev client.

devakrishna33 commented 1 year ago

You can build a dev client but because of it's dependency to react native device info it'll throw an error stating react native device info is not defined.

Inorder to make this work you can try the following,

In babel.config.js add an alias to react native device info,

const config = {
  plugins: [
    [
      require.resolve('babel-plugin-module-resolver'),
      {
        root: ['.'],
        alias: {
          // Add this line
          "react-native-device-info": "./react-native-device-info.js"
        },
      },
    ],
  ],
}

And in react-native-device-info.js add this

import Constants from "expo-constants"

export const getVersion = () => {
    return Constants.expoConfig?.version
}

This will replace the getVersion function from react-native-device-info. Make sure to restart the expo server with "--clear".

krisgerhard commented 1 year ago

@devakrishna33 Thank you so much!!! Tested, works!

@SudoPlz maybe this workaround is worth adding to readme as well? Widens the potential usages a lot.

SudoPlz commented 1 year ago

@devakrishna33 thank you for this workaround, I wasn't aware of it.

@krisgerhard feel free to open a PR, with a link to this solution, and I'll be happy to approve.