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
Use server API which will store version info
Like you said.This is an easy way to detect an update. Pass your version info with every API calls. When playstore is updated change the version in server. Once the server version is higher than installed app version, you can return a status code/message in API response which can be handled and update message can be showed. You can also block users from using very old app like WhatsApp do if u use this method.
Or you can use push notification, which is easy to do...Also
I suspect that the main reason for requesting app's version is for prompting user for update. I am not in favour of scrapping the response, because this is something that could break functionality in future versions.
If app's minimum version is 5.0, you can implement in-app update according to the documentation https://developer.android.com/guide/app-bundle/in-app-updates
If the reason of requesting apps version is different, you can still use the appUpdateManager in order to retrieve the version and do whatever you want (e.g. store it in preferences).
For example we can modify the snippet of the documentation to something like that:
// Creates instance of the manager.
val appUpdateManager = AppUpdateManagerFactory.create(context)
// Returns an intent object that you use to check for an update.
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
// Checks that the platform will allow the specified type of update.
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
val version = appUpdateInfo.availableVersionCode()
//do something with version. If there is not a newer version it returns an arbitary int
}
For PHP
$package='com.whatsapp';
$html = file_get_contents('https://play.google.com/store/apps/details?id='.$package.'&hl=en');
preg_match_all('/<span class="htlgb"><div class="IQ1z0d"><span class="htlgb">(.*?)<\/span><\/div><\/span>/s', $html, $output);
print_r($output[1][3]);