Skip to main content

In App Updates

In-App Updates is a method for your application to check with the store as to whether there is a newer version of your application available. Although some users enable background updates when their device is connected to an unmetered connection, other users may need to be reminded to update.

This feature allows you to check and prompt active users to update your app.

Additional Requirements

There may be some additional requirements here depending on how you installed the extension.

Nothing additional required if using apm.

Usage

Check if supported

Only certain services support In-App Updates:

  • Google Play
  • Huawei AppGallery

You can use the isSupported flag to check whether the current device and service supported In App Updates:

if (InAppBilling.service.inAppUpdates.isSupported)
{
// In-App Updates are supported
}

Check for an update

To check for an update, call checkAppUpdate() and await one of the events:

  • InAppUpdatesEvent.CHECK_APP_UPDATES_SUCCESS: dispatched when the check was completed successfully
  • InAppUpdatesEvent.CHECK_APP_UPDATES_FAILED: dispatched if there was an error performing the check.
InAppBilling.service.inAppUpdates.addEventListener( InAppUpdatesEvent.CHECK_APP_UPDATES_SUCCESS, successHandler );
InAppBilling.service.inAppUpdates.addEventListener( InAppUpdatesEvent.CHECK_APP_UPDATES_FAILED, failedHandler );

InAppBilling.service.inAppUpdates.checkAppUpdate();

If successful you can use the details in the event to determine if there is an update available:

function successHandler( event:InAppUpdatesEvent ):void
{
if (event.updateAvailability == InAppUpdateAvailablity.UPDATE_AVAILABLE)
{
// An update is available
trace( "info: " + (event.updateInfo == null ? "null" : event.updateInfo.toString()) );
}
else
{
// No update available
}
}

If an error occurred you can use the errorCode and message fields to understand the issue:

function checkAppUpdates_failedHandler( event:InAppUpdatesEvent ):void
{
trace( "errorCode: " + event.errorCode );
trace( "message: " + event.message );
}

Start an update

If there is an update available, you can start the in app update process by calling startAppUpdate():

InAppBilling.service.inAppUpdates.startAppUpdate();

Testing

Google Play

With internal app sharing, you can quickly share an app bundle or APK with your internal team and testers by uploading the app bundle you want to test to the Play Console.

You can also use internal app sharing to test in-app updates, as follows:

  1. On your test device, make sure you've already installed a version of your app that meets the following requirements:
  • The app was installed using an internal app sharing URL
  • Supports in-app updates
  • Uses a version code that's lower than the updated version of your app
  1. Follow the Play Console instructions on how to share your app internally. Make sure you upload a version of your app that uses a version code that's higher than the one you have already installed on the test device.

  2. On the test device, only click the internal app-sharing link for the updated version of your app. Do not install the app from the Google Play Store page you see after clicking the link.

  3. Open the app from the device's app drawer or home screen. The update should now be available to your app, and you can test your implementation of in-app updates.