How to notify users about an Android app update?
Asked Answered
S

17

62

I've built an Android app which is now on Play Market. From time to time, I make updates to it, and I'd like to let users know that a new version is available.

How can I send an update notification to the users of the app?

Salt answered 24/3, 2012 at 7:14 Comment(2)
As far as I've seen it, it's usually done in-app, ie. when the app launches it checks for a new version itself and displays a notification to the user to update.Fortin
This open source GitHub project (MAHAndroidUpdater)is completely providing update functionality. Try it, Very simple. github.com/hummatli/MAHAndroidUpdaterHarte
G
69

You do not need to do anything specific for this. Since you mentioned that you are using Google Play, the update notification is taken care of by Google Play.

You just need to update the APK with a higher versionCode and Google Play should do the rest.

Gum answered 26/3, 2012 at 19:16 Comment(17)
I change the android:versionCode attribute in AndroidManifest.xml file each time I modify the code, but i don't get any notice on my phone.Salt
@doledoug, make sure 1. Notifications in Google Play - Settings is ticked. 2. Background date in your phone Settings - Accounts and sync is ticked.Frontiersman
@doledoug: You may not get the notification right away as it depends on the Android Play. Make sure you are connected to the internet.Gum
@Frontiersman where are those notifications in Google Play?Salt
Open Google Play, Click hard Menu Button then Settings. You will see Notifications under General category.Gum
Also note that the system distinguishes between an unsigned and signed installation of your app, so don't expect your unsigned test application to update if you upload a signed app to the store.Loya
@WillKru It's not unsigned app. A test app needs to be signed, then it can be installed. I think the system does not care if the app was installed from "unknown sources" -- not from Google Play.Micra
@haibison sorry, I meant signed using a test signature instead of a production signature. When testing Eclipse will automatically sign it using the test signature so it looks like you're not signing itLoya
Actually, I do not get update notifications from Google Play when I upload a new version, with new versionCode. The checkbox for "notify me" in Google Play is checked...Agler
@Agler You should get a notification, do you get notification at all from Play regarding other apps? Do you have previous signed version of the app installed on your device?Gum
I get it for some others, yes, but not my app. I have no idea why. I can see that there is a new version on Play, and if I click it, then i can "update", but I get no notifications.Agler
@Gum https://mcmap.net/q/323560/-download-content-when-app-is-updated-via-google-play/1503130 I have posted a question here somewhat related to what happens next after update starts.Sheaves
Actually, id prefer my own app to be able to search/find the app on google play, wheck the version number and then react. The notifications from Google Play are not reliable, and I cannot force an update, which I would be able to if I could query Google PLay.Agler
but how we can get version code of play store for check ?Wad
Some users turn off the auto update in Google Play settings and keep using old versions of fof months. So I prefer to notify such users inside the app. This link is helpfulhttps://mcmap.net/q/323561/-checking-my-app-version-programmatically-in-android-marketMoise
How can i use in chine? China doesn't except Google play store ?Wifehood
"Google Play should do the rest" ok, great... so wait and cross your fingers for Google to notify the user, then wait and cross your fingers for the user to apply the update. No thank you. I'd rather have explicit controls through in-app logic, where at key points I check for version difference and take appropriate action (like force an immediate update).Maines
L
13

Update 2020: now you can use in-app updates mechanism

Preview

Docs: https://developer.android.com/guide/playcore/in-app-updates

Lurid answered 1/5, 2020 at 13:26 Comment(1)
how can i customize the above popupVetchling
R
12

You can do this in a lot of ways, depending on when you want the user to be able to see that there is an update available.

If you want the user to know about the update when the app is started, just create a utility method (inside the onCreate method of your main/first Activity) that checks if a newer version is available in Google Play. If it does, display an alert dialog with a relevant message and an Intent which opens your app in Google Play when the user clicks on the positive button of the alert dialog. If you are updating the app regularly, the user will keep getting this alert dialog every time the app is started and hence, may get irritated. Thus, this is not the best approach.

If you want the user to get a notification on the phone (and not when the user starts the app), you can use the AlarmManager class to schedule a background service which checks for an update at regular intervals. If the service finds that an upgrade is actually available, publish a notification with an intent that opens your app in Google Play.

Of course, another approach is to leave it to the OS itself. If the user has not set the "Automatically update" preference for your app, the user will get a notification regularly about an update available for your, as well as any other apps. But not all users enable background data on their devices, so this is not completely reliable.

In the end, you must respect the users preferences. If the user does not want to automatically update the app, or does not want to see a nagging dialog box whenever he/she starts your app, don't alert the user about the update.

In my opinion, you should create a PreferenceActivity that has a preference like "Check for updates regularly", which can be set from within your app. If it is set, do the needful in your own service. May be even give the user an option to select the period after which the service will check for an update.

I hope this helps!

Rolanda answered 27/3, 2012 at 10:21 Comment(2)
I would really like to discourage the use of the AlarmManager to run your app in the background to check for updates. Imagine if every app the user installed did this. Your app is just not that important, and it is rude to waste the user's device's resources like this. And don't use the addition of a preference as an excuse to allow you to do this, if you are defaulting that preference to true. Most users will never look for that, and it is those users in particular who are most at the mercy of poor device performance from abusive app developers.Repetitious
How do you suggest one should "check if a newer version is available in Google Play" reliable. As far as my knowledge goes API is not public except for a unofficial version ?Shanitashank
S
12

It is up to each phone owner if she wants to be notified on new versions by google play, and it's up to each phone's manufacturer if this is to be enabled by default.

If you however are in a situation where you "require" the user to update to the new version to be compatible with some form of protocol or you have a similar similar use case where you have a server component somewhere, you might want to notify the user of a potential version conflict in the UI based on information about what is the latest version.

This information can be grabbed directrly from google play, however as @Yahel pointed out in this question google play is a closed system with no official API, and you might need to rely on unpredictable undocumented API. There is an unofficial API library here.

This leaves only one option, which is to keep this information on your own server. If you allready have a serverside this might be trivial. Simply put the latest version in an XML file and retreive that at regular intervals from your code. If the version code is outdated, trigger the notification in your UI. Here is an example implementation for doing that.

I hope this was helpful :-)

Saltwort answered 1/4, 2012 at 21:10 Comment(0)
A
7

I know this is an old question but still if people are coming here to check this question, Google is now providing official support for in-app notification for application update the full documentation can be found here

Aurora answered 4/7, 2019 at 10:13 Comment(1)
Can i able to customize the popupVetchling
D
4

Use this : https://www.push-link.com/

Deadening answered 24/3, 2012 at 7:27 Comment(2)
this approch doesn't add advertising or something else to my app?Salt
as far as I know there wont be advertisingDeadening
D
3

Google Play will notify your users that the app has an update via the notification bar.

If you set up a notification system yourself, the likely result would be that, although the user is notified of an update sooner, when he/she goes to Google Play to install the update it will not yet be available. This is because there is a lag from the time you "publish" an app/update and the time until it appears on Play. Telling your users that there is an update when the update is unavailable would only lead to confusion and frustration.

My advice: stick with Google's update notification system and don't worry about trying to get users an update 15 minutes sooner.

Demimonde answered 31/3, 2012 at 5:18 Comment(1)
I dont get a notification from Google Play when I update my apk-file with a newer versionCode... Cant understand why, i checked all settings etc.Agler
I
2

Some people use Android Cloud-to-Device Messaging (C2DM) to notify their users of updates. I don't think I'd bother, since I think Google Play does a pretty good job of notifying me of updates already, and implementing C2DM adds a whole new dimension to writing an app (because it requires a server component). But maybe you want to offer your users a richer update notification than you get from Google Play.

Innkeeper answered 1/4, 2012 at 20:56 Comment(0)
A
2

@Davek804's answer above is wrong. android:versionCode is an integer value that represents the version of the application code, relative to other versions, so using "1.5b" there is incorrect. Use "15" (or "150") instead

Amphitrite answered 17/7, 2012 at 9:38 Comment(0)
G
2

Found a nice solution for your problem: Let´s say you want to check for version updates manually on app start and notify your users for the new Update.

Step 1: Download android-market-api (not the .jar file, the full project!)

Step 2: After importing it to eclipse, write in your activity the following code:

MarketService ms = new MarketService(activity);
ms.level(MarketService.REVISION).checkVersion();

now, we need to modify MarketService.java, because it seems to be broken.

Step 3: rewrite callback method and add the following methods

protected void callback(String url, JSONObject jo, AjaxStatus status){      
        if(jo == null) return;
        String googlePlayversion = jo.optString("version", "0");
        String smartphone_version = "";

        PackageInfo pInfo;
        try {
            pInfo = act.getPackageManager().getPackageInfo(act.getPackageName(), 0);
            smartphone_version = pInfo.versionName;
        } catch (NameNotFoundException e) {}
        boolean new_version_avaible = compare(smartphone_version, googlePlayversion);
        if(new_version_avaible){
            showUpdateDialog(jo);
        }
    }

    private static boolean compare(String v1, String v2) {
        String s1 = normalisedVersion(v1);
        String s2 = normalisedVersion(v2);
        int cmp = s1.compareTo(s2);
        String cmpStr = cmp < 0 ? "<" : cmp > 0 ? ">" : "==";
        System.out.printf("result: "+"'%s' %s '%s'%n", v1, cmpStr, v2);
        if(cmpStr.contains("<")){
            return true;
        }
        if(cmpStr.contains(">")||cmpStr.contains("==")){
            return false;
        }
        return false;
    }

    public static String normalisedVersion(String version) {
        return normalisedVersion(version, ".", 4);
    }

    public static String normalisedVersion(String version, String sep, int maxWidth) {
        String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
        StringBuilder sb = new StringBuilder();
        for (String s : split) {
            sb.append(String.format("%" + maxWidth + 's', s));
        }
        return sb.toString();
    }

If you want to test it, modify googlePlayversion string to a higher version than your local one.

The source comparison method I used is from How do you compare two version Strings in Java?

Germaun answered 26/8, 2013 at 16:23 Comment(1)
Why compare the version names when you can just compare the version codes directly?Dygal
D
2

There is also a very good approach for checking version and give user in app notification or when you want to forcefully update the application if you can decide the first connection of your app with the server.In the response of the first request you can send the current version of app stored on your server and then on client end you can take the appropriate action. Advantages of this approach-:
1-No extra request for version no.
2-It is also applicable if you are downloading the app other than the google playstore.
3-you can also use this idea if you want to check the version at particular operation of your app ex- transaction(if you add a new payment gateway.)

Dimond answered 10/6, 2016 at 7:41 Comment(0)
A
1

Don't know if you want to walk extra miles. You can try out google appengine, which serve version number for your app and let you android app check the appengine to see if there is a new version when the application is launched. That way, it does not matter if your app is in google play market nor amazon app store nor if it is installed on the phone without those two via sideloading. It is not very hard to setup appengine just for serving your application version in json. Replace "Hello World" string with your app version name ...

Adi answered 30/3, 2012 at 6:41 Comment(0)
B
1

This can be using a simple webservice just this is one of the way to acheive.

i.e., when ever the app launch hit that webservice with the current version of the user app and on the server you need to check whether any new version is available or not(Must maintain the newest version of the app) and send the corresponding response to the user. If any newer version is available prompt the user to download the newest version of the application and if no newest version is available then allow the user to continue.

Hope so atleast something must be useful to you.

Beforehand answered 1/4, 2012 at 8:39 Comment(0)
A
1

There are two models that are basically used to tackle the issue.

Pull Based
Push Based

Its depends on the architecture or design of particular system that determines whether pull based or push mechanism is used.

For pull based model you just make one http request to concerned server regarding the new version of application. The current application version no can be saved in SQLLite in android application. This can be given to server and new version can be checked against it at the server.

For push mechanism you can use C2DM push notification service.. details of which are given at http://code.google.com/android/c2dm/

Alfilaria answered 2/4, 2012 at 16:47 Comment(0)
R
0

Generally when you upload a new application to Google play most users get a notification about an update, some will have the app automatically downloaded to their device, depending on the settings they have. If you seriously want to make a notification from your app to ask them to update (so that everyone gets the notification, whatever their Google play settings are, then you will have to make a web service which returns the number of the newest version. You can then compare that inside your app and post a notification. You could use Google App Engine ( https://developers.google.com/appengine/) because that works with eclipse and java, which you probably already have. I would not recommend this approach as it creates a lot of work for you to provide something that most users have already got.

Roa answered 2/4, 2012 at 8:17 Comment(0)
S
0

i think this is too late but it can be help some one

public enum AppVersionUpgradeNotifier {
INSTANCE;

private static final String TAG = "AppVersionUpdateManager";

private static final String PREFERENCES_APP_VERSION = "pref_app_version_upgrade";
private static final String KEY_LAST_VERSION = "last_version";

private SharedPreferences sharedPreferences;
private VersionUpdateListener versionUpdateListener;
private boolean isInitialized;

public static synchronized void init(Context context, VersionUpdateListener versionUpdateListener) {
    if (context == null || versionUpdateListener == null) {
        throw new IllegalArgumentException(TAG + " : Context or VersionUpdateListener is null");
    }

    if (!INSTANCE.isInitialized) {
        INSTANCE.initInternal(context, versionUpdateListener);
    } else {
        Log.w(TAG, "Init called twice, ignoring...");
    }
}

private void initInternal(Context context, VersionUpdateListener versionUpdateListener) {
    this.sharedPreferences = context.getSharedPreferences(PREFERENCES_APP_VERSION, Context.MODE_PRIVATE);
    this.versionUpdateListener = versionUpdateListener;
    this.isInitialized = true;
    checkVersionUpdate();
}

private void checkVersionUpdate() {
    int lastVersion = getLastVersion();
    int currentVersion = getCurrentVersion();

    if (lastVersion < currentVersion) {
        if (versionUpdateListener.onVersionUpdate(currentVersion, lastVersion)) {
            upgradeLastVersionToCurrent();
        }
    }
}

private int getLastVersion() {
    return sharedPreferences.getInt(KEY_LAST_VERSION, 0);
}

private int getCurrentVersion() {
    return BuildConfig.VERSION_CODE;
}

public void upgradeLastVersionToCurrent() {
    sharedPreferences.edit().putInt(KEY_LAST_VERSION, getCurrentVersion()).apply();
}

public interface VersionUpdateListener {
    boolean onVersionUpdate(int newVersion, int oldVersion);
}

}

use it on

public class MyApplication extends Application implements AppVersionUpgradeNotifier.VersionUpdateListener {

@Override
public void onCreate() {
    super.onCreate();

    AppVersionUpgradeNotifier.init(this,this);
}

@Override
public boolean onVersionUpdate(int newVersion, int oldVersion) {
    //do what you want

    return true;
}

}

Slavophile answered 1/2, 2019 at 11:39 Comment(0)
P
-8
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1.5b" 
android:versionName="1.5b">

When you re-upload your app to Google Play, if these two attributes have been changed from the previous upload, Google Play will automatically send notifications to users who have installed your app. This is the AndroidManifest file.

Poetics answered 1/4, 2012 at 19:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.