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

iOS not working #179

Open
mezalejandro opened this issue Oct 10, 2022 · 2 comments
Open

iOS not working #179

mezalejandro opened this issue Oct 10, 2022 · 2 comments

Comments

@mezalejandro
Copy link

Hello,
on iOS i have this error:
No info about this app.
When i do this:
VersionCheck.needUpdate().then(async res => { console.log('res ', res); // true });
I have this version: ^3.4.3

Thanks

@hanabalon
Copy link

hanabalon commented Oct 27, 2022

This is how I was get it working:

  1. First I define this method to get app info from itunes.
const getIOSProvider = async (appStoreURL) => {
  return await fetch(appStoreURL)
    .then((response) => {
      const res = response?.json()?.then((info) => {
        return info?.resultCount > 0 ? info.results : null
      })
      return res
    });
}
  1. Call the method mentioned above on the component to set appVersion as a state:

const App = () => {
  const [appVersion, setAppVersion] = useState() // set appVersion from iTunes
  const [storeURL, setStoreURL] = useState('')
  const appStoreURL = `https://itunes.apple.com/${country}/ookup?bundleId=${packageName}` // iTunes API URL of your package

  getIOSProvider(appStoreURL).then(res => {  // call method
    if (res[0]) {
      setAppVersion(res[0].version) // marketing version
      setStoreURL(res[0].trackViewUrl) // I set this URL to show user the app link
    }
  })

  if (appVersion) {
    VersionCheck.needUpdate({
      currentVersion: VersionCheck.getCurrentVersion(), // this returns the version setted on the last build
      latestVersion: appVersion
    })
        .then(res => console.log('VersionCheck', res));
  }

@HaNguyenSavvy
Copy link

I have try on the postman but get this { "resultCount":0, "results": [] }

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

No branches or pull requests

3 participants