0

i'm new in programming I just wanna ask if someone can help me with my problem. I've built an app and its now on the play store, I'm just wondering if how can I send notification update to the users of the app?

I just want to put up an popup to the User when they open the App. And tell them "There is a newer version of this app. Click here to update" and then it takes them to the app store. Thank you!

  • check this- https://stackoverflow.com/questions/51241855/getting-latest-app-version-from-play-store-xamarin – R15 Nov 26 '18 at 08:39

3 Answers3

2

There is no official api from google which can tell you to update.

instead you can have you own API which returns the current version and check at app end with existing version to show update dialog.

You can also use few tools like leanplum etc to do so.

0

First thing leave it to OS itself, if the user has set "Automatically Update" preference for your app, the google play will take care of it.

If you want the user to know about the update when the app is started the best thing you can do is to first update the version number on your server and when the app is being launched check for the version number, If the version code is higher on the server, then your app needs to be updated and you can tell the user accordingly Do this inside the first activity/launch activity inside onCreate.

If you want this to happen, without any coding stuff Look Here

Happy Coding.

Abhishek P
  • 58
  • 1
  • 12
-1

Check your new app version from this code with asynctask

@Override
protected String doInBackground(Void... voids) {

String newVersion = null;
try {
    newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + MainActivity.this.getPackageName() + "&hl=it")
            .timeout(30000)
            .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
            .referrer("http://www.google.com")
            .get()
            .select(".hAyfc .htlgb")
            .get(7)
            .ownText();
    return newVersion;
} catch (Exception e) {
    return newVersion;
}
}

@Override
protected void onPostExecute(String onlineVersion) {
super.onPostExecute(onlineVersion);

Log.d("update", "playstore version " + onlineVersion);
}

And check your current version from here

PackageManager manager = getPackageManager();
PackageInfo info = null;
try {
    info = manager.getPackageInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
    e.printStackTrace();
}
assert info != null;
version = info.versionName;

if both version is not match then show alert dialog to user

Chetan Shelake
  • 656
  • 1
  • 6
  • 14