Skip to main content

In-app update for Windows apps

In-app update is a separate library from AppticsAnalytics and is used to show in-app update alerts in UWP apps as per the configuration done in the Apptics web console. Refer to the user guide to do the configuration in the web console.

Integrate in-app updates in Windows

  • Configure the in-app updates in the Apptics web console, refer to the User Guide.
  • Add AppticsAppUpdate(uwp) or WinUIAppticsInAppUpdate(WinUI) library reference (dll) into your project from the downloaded Apptics dlls.

Set developer option

You can choose to check for app updates either by the developer at runtime or by the SDK itself on every app launch.

  • if you wish to handle the app update from the SDK itself, you don't have to do any extra steps.
  • if you wish to check it by the developer.
    • Add the below line of code in the OnLaunched function of your App.xaml.cs after the usual Apptics init function.

For UWP apps

CopiedAppticsAppUpdate.AppUpdateHelper.SetAppUpdateFlag(true);

For WinUI apps

CopiedWinUIAppticsInAppUpdate.AppUpdateHelper.SetAppUpdateFlag(true);

If you set the above function to true, Apptics SDK won't check for an app update automatically, you will have to check for it, by using the below function.

For UWP apps

CopiedAppticsAppUpdate.AppUpdateHelper.CheckForAppUpdate();

For WinUI apps

CopiedWinUIAppticsInAppUpdate.AppUpdateHelper.CheckForAppUpdate();

Set your Popup style

You can customize your popup, by using the 'PopupStyle defined by Apptics.

For UWP apps

CopiedPopupStyle popupStyle = new PopupStyle(){TitleFontSize=12};
AppUpdateHelper.SetPopupStyle(popupStyle);

For WinUI apps

CopiedAppUpdatePopupStyle popupStyle = new AppUpdatePopupStyle(){TitleFontSize=12};
AppUpdateHelper.SetPopupStyle(popupStyle);

Custom UI

  • If you would like to show your own pop-up for app update, you can call the respective functions from the SDK based on the user input.
  • Set the custom UI boolean to true.

For UWP apps

CopiedAppticsAppUpdate.AppUpdateHelper.CustomUI = true;

For WinUI apps

CopiedWinUIAppticsInAppUpdate.AppUpdateHelper.CustomUI = true;
  • Register for ShowAppUpdatePopup event from the SDK. This will be triggered whenever the app update is available and you can show the custom pop-up.

For UWP apps

CopiedAppticsAppUpdate.AppUpdateHelper.ShowAppUpdatePopup += AppUpdateHelper_ShowAppUpdatePopup;

For WinUI apps

CopiedWinUIAppticsInAppUpdate.AppUpdateHelper.ShowAppUpdatePopup += AppUpdateHelper_ShowAppUpdatePopup;

Note: Make sure that you have this event registered after your MainPage InitializeComponent. If you register this in App.xaml.cs, make sure that the Apptics init function is completed before the event registration. 

Sample showAppUpdatePopup

For UWP apps

Copiedprivate async void AppUpdateHelper_ShowAppUpdatePopup(long updateId, AppticsAppUpdate.Enums.PopupEnums.PopupOption popupOption, AppticsAppUpdate.Enums.PopupEnums.NonSupportedAlertType nonSupportedAlertType)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
                InAppUpdateDialog inAppUpdateDialog = new InAppUpdateDialog(updateId);
                await inAppUpdateDialog.ShowAsync();
            });

        }

For WinUI apps

Copiedprivate async void AppUpdateHelper_ShowAppUpdatePopup(long updateId, AppticsWindowsBase.Enum.AppUpdatePopupEnums.PopupOption popupOption)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
                InAppUpdateDialog inAppUpdateDialog = new InAppUpdateDialog(updateId);
                await inAppUpdateDialog.ShowAsync();
            }
  • You can handle the pop-up UI as per the alert type. You can get all the app update details by using the below function.

For UWP apps

CopiedAppUpdate appUpdateRootInstance = AppticsAppUpdate.AppUpdateHelper.GetAppUpdateDetails();

For WinUI apps

CopiedAppUpdate appUpdateRootInstance = WinUIAppticsInAppUpdate.AppUpdateHelper.GetAppUpdateDetails();
  • Send the pop-up response data to the server using the following functions.
    • Whenever the pop-up is shown, send impression to the server.

For UWP apps

CopiedAppUpdateHelper.SendPopupResponseStates(PopupActionEnum.impression, updateId);

For WinUI apps

CopiedAppUpdateHelper.SendPopupResponseStates(PopupActionEnum.impression, updateId);
  • If the user selected 'Update Now', use the below function.

For UWP apps

CopiedAppUpdateHelper.DownloadUpdateSelected(updateId);

For WinUI apps

CopiedAppUpdateHelper.DownloadUpdateSelected(updateId);
  • If the user selected 'Ignore', use the below function.

For UWP apps

CopiedAppUpdateHelper.IgnoreUpdateSelected(updateId);

For WinUI apps

CopiedAppUpdateHelper.IgnoreUpdateSelected(updateId);
  • Whenever the user has clicked any option in the pop-up, call the below function to maintain the reminder count. If the user didn't choose an option, do not call the below function.

For UWP apps

CopiedAppticsAppUpdate.AppUpdateHelper.SaveReminderDateAndCount();

For WinUI apps

CopiedAppticsAppUpdate.AppUpdateHelper.SaveReminderDateAndCount();
  • You can set the different OS versions of Windows, to test the 'NonSupportedOS' type pop-up. Make sure you use the proper OS version format (refer to the example).
  • Use 'true' for debugOnly to make sure this custom OS version doesn't impact the release mode.

For UWP apps

CopiedAppticsUwpBase.Initializer.Instance.CustomizeOSVersion = true;

AppticsUwpBase.Initializer.Instance.SetOsVersionForTestingPurpose("10.0.14393", true);

For WinUI apps

CopiedWinUISdkBase.Initializer.Instance.CustomizeOSVersion = true;
WinUISdkBase.Initializer.Instance.SetOsVersionForTestingPurpose("10.0.14393", true);