chronogolf / nativescript-store-update

Apache License 2.0
19 stars 13 forks source link

Better way to get release date from Google Play #20

Open codeback opened 7 years ago

codeback commented 7 years ago

Thanks for this amazing plugin.

I have problems getting the release date. Depending of the country code I'm getting the date in different formats:

https://play.google.com/store/apps/details?id=com.bitstrips.imoji&hl=en
November 22, 2017

https://play.google.com/store/apps/details?id=com.bitstrips.imoji&hl=es
22 de noviembre de 2017

In both cases I'm getting NaN in the line 134 of store-update.common.js file:

// releaseDate = '22 de noviembre de 2017 or 'November 22, 2017'
var daysSinceRelease = moment().diff(moment(new Date(releaseDate)), 'days');

The problem is that the confirm dialog is never shown.

Is there a way to get this date in an ISO format (and independent of the country code)?

Thanks in advance.

SBats commented 7 years ago

Hi @codeback, Mm, in fact, it's something needing a fix. Moment should be used to convert the string to a common format. If you want to create a PR for this, feel free. Otherwise, we'll investigate it as soon as we have a moment. Thank you for the heads up!

codeback commented 7 years ago

Hi @SBats,

Thank you for your response. The problem is that it is difficult to parse the string because this string will be different depending on the country code.

A possible solution would be to make this request always in 'en'. This way we would get the date always in the same format (November 22, 2017) and we could then parse to a date with Moment.

Is there a reason to get the market info with the localized info?

Please tell me if the proposed solution would be valid. If it is, I'll make a pull request with the changes.

SBats commented 7 years ago

Mm I'm not sure but I think an app can be published in only selected store (for example published in es but not in en). So always using en could cause an issue if the person hasn't published it in this language. On another hand, Moment is Supposed to handle a lot of locale so I think it could parse a full text version, as long as we specify the format as second parameter. Those are hypothesis though, I need to check.

jeremypele commented 7 years ago

Hi @codeback,

The country code is indeed setup because not everyone publish everytime on every store. For instance you may wanna do a panel testing on a specific country before releasing to the entire world.

Other case: you may be a Portuguese company that will only release your app in Portugal (thus en default lang will never return a valid version)

codeback commented 7 years ago

Yes I think you are right, but I don't know if it is done with the hl param (like it is in the code).

I have an app published in Spain only and I can access it with hl=fr, for example.

Can you check if you can access?

jeremypele commented 7 years ago

Yes I can access it. If you have a single store to manage or deploy to all the stores in the same time, there's no real issue as you can set the locale you want.

codeback commented 7 years ago

@jeremypele, I'm not sure If I've understood correctly. Then the proposed solution (hl=en) would be valid?

If we can find a solution of getting always the same format, the Moment dependency could be removed since it is only used in that line, and we would save a few bytes ;)

codeback commented 7 years ago

Hi @SBats and @jeremypele, I've just tested it on iOS.

While in Android I can access to the Google Play info independently of the country code, in iOS you can't if the app is published in a country (as you said). So, I don't know a good way to do this, since I have two problems now :(

Ohh, I think there is a bug in the way the url is built in iOS. It should be https://itunes.apple.com/{{countrycode}}/lookup?bundleId={{bundleId}}

SBats commented 7 years ago

For the Apple store URL, I'll check, thanks for the heads up.