2

I have an app published in the Play and App store, now I am in the work of publishing a new version for the app to both Play (Android) and App stores (iOS). Now, I want all the users to update to the new version when they use the app and not allow them to continue using the older version of the app without updating to the newer version.

Can anyone suggest me on how to force the users to update the app to the latest version once it is released in Play and App stores?

halfer
  • 19,824
  • 17
  • 99
  • 186
Vijay457
  • 324
  • 2
  • 11

4 Answers4

1

We must stop the old versions in the Play and App store.

For the future to do not stop (if we have some host - we should have it :) ):

  • someway save the version in the server side
  • every time when needed check the current version: getPackageManager().getPackageInfo(getPackageName(), 0).versionCode with version from server and force to update if needed.

good luck

Hovanes Mosoyan
  • 760
  • 7
  • 10
  • For this to work, this code has to be included in the existing app in the Play and App store right.? which i have not included while i publish the app. I am looking for any way we can enforce this while publishing the app update. @Hovanes Mosoyan – Vijay457 Jul 11 '18 at 06:00
  • Yes, you are right. For the case we have - We must stop the old versions in the Play and /or App store. The feature we want to use could be in the App Store, or Google Play, but I ca't find a feature like that there ) – Hovanes Mosoyan Jul 11 '18 at 07:06
1

I don't know whether it is professional way or not., but this is the idea which struck my mind.

Add a variable with that app's version in App.cs or Mainpage.cs and and API with the current version as response.

Now check with the app's version and current version and redirect to homepage / any other page.

var version = 1.0;
var currentversion = 2.0; /* from API */
if(version == currentversion)
{
  Navigation.PushModalAsync(new HomePage());
}
else
{
  Navigation.PushModalAsync(new UpdatePage());
}
Senthamizh
  • 281
  • 1
  • 4
  • 12
  • For this to work, this code has to be included in the existing app in the Play and App store right.? which i have not included while i publish the app. I am looking for any way we can enforce this while publishing the app update. @senthamizh – Vijay457 Jul 11 '18 at 05:59
  • Sorry bro., No idea on that. GooglePlay will notify if there is an update in playstore, but to force an user to update without the above method is not possible to my knowlege. – Senthamizh Jul 11 '18 at 07:09
1

How I am doing it my app is, when app starting in MyActivity I have code below

private void CompareVersion()
{
    double currentVersion = 0d;
    double appStoreversion =Convert.ToDouble(CosntValues.PlayStoreValues);
    bool IsUpdateRequired = false;

    if (Context.PackageName != null)
    {
        PackageInfo info = Context.PackageManager.GetPackageInfo(Context.PackageName, PackageInfoFlags.Activities);
        string currentVersionStrig = info.VersionName;
        currentVersion = Convert.ToDouble(currentVersionStrig);
    }
    try
    {
        if (IsUpdateRequired == false)
        {
            if (CheckNetConnection.IsNetConnected())
            {
                using (var webClient = new System.Net.WebClient())
                {
                    var task = new VersionChecker();
                    task.Execute();
                    if ((appStoreversion.ToString() != currentVersion.ToString() && (appStoreversion > currentVersion)))
                    {
                        IsUpdateRequired = true;
                    }
                }
            }
        }
        if (IsUpdateRequired)
        {
            Activity.RunOnUiThread(() =>
            {
                AlertDialog dialog = null;
                var Alertdialog = new Android.App.AlertDialog.Builder(Context);
                Alertdialog.SetTitle("Update Available");
                Alertdialog.SetMessage($"A new version of [" + appStoreversion + "] is available. Please update to version [" + appStoreversion + "] now.");
                Alertdialog.SetNegativeButton("Cancel", (sender, e) =>
                {
                    if (dialog == null)
                    {
                        dialog = Alertdialog.Create();
                    }
                    dialog.Dismiss();
                });
                Alertdialog.SetPositiveButton("Update", async (sender, e) =>
                {
                    string appPackage = string.Empty;
                    try
                    {
                        appPackage = Application.Context.PackageName;
                        await Utilities.Logout(this.Activity);
                        var ints = new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + appPackage));
                        ints.SetFlags(ActivityFlags.ClearTop);
                        ints.SetFlags(ActivityFlags.NoAnimation);
                        ints.SetFlags(ActivityFlags.NewTask);
                        Application.Context.StartActivity(ints);
                        //StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + "com.sisapp.in.sisapp")));
                    }
                    catch (ActivityNotFoundException)
                    {
                        var apppack = Application.Context.PackageName;
                        //Default to the the actual web page in case google play store app is not installed
                        //StartActivity(new Intent(Intent.ActionView, Android.Net.Uri.Parse("https://play.google.com/store/apps/details?id=" + "com.app.in.app")));
                        await Utilities.Logout(this.Activity);
                        var ints = new Intent(Intent.ActionView, Android.Net.Uri.Parse("market://details?id=" + appPackage));
                        ints.SetFlags(ActivityFlags.ClearTop);
                        ints.SetFlags(ActivityFlags.NoAnimation);
                        ints.SetFlags(ActivityFlags.NewTask);
                        Application.Context.StartActivity(ints);
                    }
                    //this kills the app 
                    Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                    System.Environment.Exit(1);
                });
                if (dialog == null)
                    dialog = Alertdialog.Create();
                dialog.Show();
            });
        }
    }
    catch (Exception ex)
    {
        var objLog = new LogService();
        objLog.MobileLog(ex, SISConst.UserName);
    }
}

Followed by two separate above used classes

public class VersionChecker : AsyncTask
{
    protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
    {
        var val1 = Jsoup.Connect("https://play.google.com/store/apps/details?id=" + "com.app.in.app" + "&hl=en")
               .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();
        var val2 = val1.Select(".htlgb");
        var val3 = val2.Get(7).ToString();
        //here mobile app version is of 3 values like 2.1, 4.2 etc
        var version = val3.Substring(val3.IndexOf(">") + 1, 3); //fetching only 3 values ex 1.1
        CosntValues.PlayStoreValues = version;
        return version;
    }
}
public static class CosntValues
{
    public static string PlayStoreValues { get; set; }
}

Disclaimer: Use your app package name & above code is statically supporting for 3 digit version like 1.1, 1.2 etc. Hope it help you

R15
  • 13,982
  • 14
  • 97
  • 173
  • This code needs to be included in the already published app in the store for it to work. But i have not done anything as this sorts while i published the app. So i am looking for an option while publishing the update in the play and app store, if there is an option like that. – Vijay457 Jul 11 '18 at 07:07
  • No, Just need to add this code in your current app irrespective to release app. – R15 Jul 11 '18 at 07:11
  • But it will not affect the users who already using the app from play store. It will work for the next app release for my app. But not for this version...! – Vijay457 Jul 11 '18 at 07:13
  • obviously! when you post new release, the users who already using your app they wont get pop-up. From second time onward they supposed to get. – R15 Jul 11 '18 at 07:17
  • Thanks.. And it seems there is no way to do this while publishing the app update as well in either the App and Play stores. – Vijay457 Jul 11 '18 at 07:19
  • No way..Just think how can you modify the app which has already been released to store. – R15 Jul 11 '18 at 07:28
  • This approach does not work anymore. Google changed the app page layout and html is different now. – Rafael Jun 20 '22 at 07:15
0

With this plugin I found a good solution and works perfectly in production. I strongly recommend this plugin. With this solution you can even give the user the possibility to go to the store right from your app

For example:

var isLatest = await CrossLatestVersion.Current.IsUsingLatestVersion();

        if (!isLatest) //If the user does not have the last version
        {
            var update = await DisplayAlert("New version available", "There is a new version of our app. Would you like to download it?", "Yes", "No");

            if (update) 
            {
                //Open the store
                await CrossLatestVersion.Current.OpenAppInStore();
            }
        }
manuelrb98
  • 344
  • 2
  • 8
  • what is the best place to put this block of code to show when I start the app? – Ashi Apr 25 '21 at 10:58
  • 1
    Well you should put this at the start of your app in order to ask your user to update. I have got some validation code on my Login page, after that I check the version. – manuelrb98 Apr 25 '21 at 15:55