How can I get the application version information from google play store for prompting the user for force/recommended an update of the application when play store applicatio
My workaround is to parse the Google Play website and extract the version number. If you're facing CORS issue or want to save bandwidth on the user's device, consider to run it from your web server.
let ss = [html];
for (let p of ['div', 'span', '>', '<']) {
let acc = [];
ss.forEach(s => s.split(p).forEach(s => acc.push(s)));
ss = acc;
}
ss = ss
.map(s => s.trim())
.filter(s => {
return parseFloat(s) == +s;
});
console.log(ss); // print something like [ '1.10' ]
You can get the html text by fetching https://play.google.com/store/apps/details?id=your.package.name
. For comparability, you may use https://www.npmjs.com/package/cross-fetch which works on both browser and node.js.
Others have mentioned parsing the html from Google Play website with certain css class or pattern like "Current Version" but these methods may not be as robust. Because Google could change the class name any time. It may as well return text in different language according to the users' locale preference, so you may not get the word "Current Version".