watanabeyu / react-native-store-version

This module check an app's version on google playstore or ios app store.
MIT License
128 stars 22 forks source link

Error: JSON Parse error: Unexpected token: < #55

Open yachtwave opened 1 year ago

yachtwave commented 1 year ago

I am intermittently seeing an exception when calling "checkVersion". The exception happens about 25% of the time. im calling the function as follows:

    let check = await checkVersion({
        version: versionLocal, // app local version
        iosStoreURL: updateConfig.urls.ios.check,
        androidStoreURL: updateConfig.urls.android.check,
        country: 'us',
    });

where variables are (expect i am using my real id# and app name) :

    ios: {
        check: 'https://apps.apple.com/us/app/yachtwave/id1234567890',
    },
    android: {
        check: 'https://play.google.com/store/apps/details?id=com.myapp.app',

Hoping you can help find the issue as it is affecting version checks - thanks!

KiranRadish commented 1 year ago

i am also having same issue [Error: JSON Parse error: Unrecognized token '<'] @jeokeefe did you found solution for this?

yachtwave commented 1 year ago

@KiranRadish I have not found a solution, we pushed our latest update with it like that. We catch the exception and then just move on...

McFlyssss commented 1 year ago

We are having the same issues here. As @jeokeefe pointed out, it does not happen every time.

watanabeyu commented 1 year ago

Hi everyone.

Sorry to reply. I will fix this, so please wait. I can probably fix this in 2 days.

thanks

watanabeyu commented 1 year ago

@jeokeefe @McFlyssss @KiranRadish I think it's because the version is no longer listed on the play store. Please yours play store url. I found there may be certain rules.

Pattern A

This app using my library. Press the button [About this app ->] and see if the version notation part in the displayed modal looks like this. Group 15

Pattern B

This app I created, and version is displayed. スクリーンショット 2023-05-25 15 58 02

What?

So, I want to check different. My app build type is .aab. Which type aab or apk your apps.

Maybe it's different depending on whether it's aab or apk. or maybe something else...

First of all, please tell me if it's aab or apk.

thanks

McFlyssss commented 1 year ago

Hi @watanabeyu ,

Thanks for taking a look into this. We actually are having those issues on the iOS side of the things. Android is working just fine for us.

watanabeyu commented 1 year ago

Umm...please your app store url

McFlyssss commented 1 year ago

Sure thing! There you go: https://apps.apple.com/app/nuvolops-crew-app/id1536764075

yachtwave commented 1 year ago

Here you go thanks! I believe this is only happening with the apple App Store (not google)“ https://apps.apple.com/us/app/yachtwave/id6447794172”Thanks! Sent from my iPhoneOn May 25, 2023, at 5:15 AM, Yu Watanabe @.***> wrote: Umm...please your app store url

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

watanabeyu commented 1 year ago

@McFlyssss Thanks url. I can get version. Enter the appstore url in the url below and try it https://snack.expo.dev/@watanabe_yu/react-native-store-version-example?platform=ios

スクリーンショット 2023-05-25 21 21 03

watanabeyu commented 1 year ago

@jeokeefe Thanks url. I can get version. Enter the appstore url in the url below and try it.

I think it's probably because I didn't put in the country. Is it because the default countryCode is jp? https://snack.expo.dev/@watanabe_yu/react-native-store-version-example?platform=ios

スクリーンショット 2023-05-25 21 24 29

yachtwave commented 1 year ago

I’ll send you my code when I get back to my desk on 1 hour. I’m using “us” and the issue only happens about 20% of the time, all others it works. It is odd. Sent from my iPhoneOn May 25, 2023, at 8:25 AM, Yu Watanabe @.> wrote: @jeokeefe Thanks url. I can get version. Enter the appstore url in the url below and try it. I think it's probably because I didn't put in the country. Is it because the default countryCode is jp? @._yu/react-native-store-version-example?platform=ios

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

yachtwave commented 1 year ago

const updateConfig = { urls: { ios: { check: 'https://apps.apple.com/us/app/yachtwave/id6447794172', }, android: { check: 'https://play.google.com/store/apps/details?id=com.yachtwave.app', } } }

let check = await checkVersion({ version: versionLocal, // app local version iosStoreURL: updateConfig.urls.ios.check, androidStoreURL: updateConfig.urls.android.check, country: 'us', });

On Thu, May 25, 2023 at 8:25 AM Yu Watanabe @.***> wrote:

@jeokeefe https://github.com/jeokeefe Thanks url. I can get version. Enter the appstore url in the url below and try it.

I think it's probably because I didn't put in the country. Is it because the default countryCode is jp?

@.***_yu/react-native-store-version-example?platform=ios

[image: スクリーンショット 2023-05-25 21 24 29] https://user-images.githubusercontent.com/6455904/240910906-086e52cb-edd0-456d-931d-3bd57dd50ebc.png

— Reply to this email directly, view it on GitHub https://github.com/watanabeyu/react-native-store-version/issues/55#issuecomment-1562817858, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7OOXAEOXSJGFVYCWDTW46DXH5FVFANCNFSM6AAAAAAX43CNAU . You are receiving this because you were mentioned.Message ID: @.***>

-- John O'Keefe CEO, YACHTWAVE

(917) 945-0186 | www.yachtwave.com | @. @.>

935 N Beneva Rd, Ste 609 PMB 2056, Sarasota, FL 34232 https://maps.google.com/?q=935+N+Beneva+Rd,+Ste+609+PMB+2056,+Sarasota,+FL+34232

McFlyssss commented 1 year ago

Hi again @watanabeyu

Thanks again for checking this out. As you can see on my screenshot I got to reproduce the error:

Screenshot 2023-05-25 at 16 45 04
watanabeyu commented 1 year ago

@jeokeefe

I’m using “us” and the issue only happens about 20% of the time, all others it works. It is odd.

Hmm, I've never encountered that phenomenon. I don't think it's a problem if you can get it even once, but maybe the iOS lookup API is sometimes strange. For the time being, I feel that this library does not seem to be... Let me know once again if you find something like that.

watanabeyu commented 1 year ago

@McFlyssss

const check = await checkVersion({
  version,
  iosStoreURL: 'https://apps.apple.com/app/nuvolops-crew-app/id1536764075',
  country:"us",
});

Could you try putting in the countryCode like this?

yachtwave commented 1 year ago

i just made the change to "us" (double quotes) ill run for a bit and provide an update.

miso-belica commented 2 weeks ago

Hello, I see this error in Sentry for our app many times. It's only iOS and the solution seems to be this https://github.com/watanabeyu/react-native-store-version/issues/46. The problem is the API call sometimes ends with the error below and HTML is probably returned instead of JSON.

GET https://itunes.apple.com/lookup
{
  http.status: 503
  http.query: id=1234567890&country=us&1727644468925,
  reason: service unavailable,
}

Also, I see no matter what HTTP header is sent API always returns response as Content-Type: text/javascript; charset=utf-8 so it's basically Javascript object but written the way it is compatible with JSON.