android 应用内更新_应用内更新灵活流程:加快Android上的应用更新过程

android 应用内更新

With a variety of new tools and features announced at Android Dev Summit, special attention should be given to the In-App Updates (IAUs) API allowing developers to increase the speed of delivering features, bug-fixes and performance improvements to active users. Since this feature was finally released after Google I/O 2019, in this article I’ll deep dive on IAUs API, describe in details recommended user flows and provide with some code samples. Moreover, I'll share some experience of IAUs integration in the Pandao app, a marketplace platform for Chinese goods.

随着Android Dev Summit宣布了各种新工具和功能,应特别注意应用内更新(IAU)API,使开发人员可以提高向活动用户交付功能,错误修复和性能改进的速度。 由于此功能终于在Google I / O 2019之后发布 ,因此在本文中,我将深入探讨IAUs API,详细描述建议的用户流程并提供一些代码示例。 此外,我将分享在IAUs整合的一些经验盼到的应用程序,一个市场平台,为中国商品。

The new API allows developers to initiate a new in-app update request flow in order to push active users to update the app. IAUs complements the existing Google Play auto-update mechanism, but, unfortunately, does not have any impact on intentions of some users to disable any kind of updates. IAUs request can be implemented in two ways, which provide the completely different user experience.

新的API允许开发人员启动新的应用内更新请求流程,以推动活动用户更新应用。 IAU对现有的Google Play自动更新机制进行了补充,但不幸的是,它对某些用户禁用任何类型的更新的意图没有任何影响。 IAU的请求可以通过两种方式实现,它们提供了完全不同的用户体验。

  1. The

    流动灵活 (flexible flow)

    prompts users to download an update in the background and install it at a convenient moment. It is supposed to be used in cases while it is still appropriate for a user to use the older version of the app while the new one was released.

    提示用户在后台下载更新并在方便的时候安装它。 应该在某些情况下使用它,尽管仍然适合用户在发布新版本的同时使用旧版本的应用程序。

  2. The

    立即流动 (immediate flow)

    requires users to download and install an update before continue using the app. It is supposed to be used in cases while it is crucial for developers to prevent usage of the app before the update is applied.

    要求用户下载并安装更新,然后才能继续使用该应用。 它应用于以下情况:对于开发人员在应用更新之前阻止其使用对于开发人员而言至关重要。

Since the latter use case is less important and appropriate for the Pandao app, we will discuss in detail the former.

由于后一种用例对于Pandao应用不太重要且不适合使用,因此我们将详细讨论前者。

IAU的灵活流程集成 (IAUs Flexible Flow Integration)

用例 (Use Case)

The flexible IAUs flow consists of the following steps.

灵活的IAU流程包括以下步骤。

  1. The app requests Google Play to check for available updates using Play Core Library.

    该应用要求Google Play使用Play核心库检查可用更新。

  2. If there is an available update, the app requests Google Play to show the IAUs dialogue. Google Play shows the update request dialogue to the user.

    如果有可用更新,则应用会请求Google Play显示IAU对话框。 Google Play向用户显示更新请求对话框。

  3. If the user accepts update request, Google Play downloads an update in the background, providing the user with graceful state monitoring at the status bar.

    如果用户接受更新请求,则Google Play会在后台下载更新,从而在状态栏为用户提供优美的状态监视。

  4. If the process of downloading completes while the app is in the background, Google Play automatically completes the installation. For cases when the download completes while the app is in the foreground, we have to define custom logic for the update completion. Consider several best-practices for the implementation.

    如果在后台运行该应用程序时下载过程完成,则Google Play会自动完成安装。 对于当应用程序位于前台时下载完成的情况,我们必须定义自定义逻辑以完成更新。 考虑实施的几种最佳实践。

    1. The app launches the installation process while displaying a Google Play screen with the installation progress to the user. After the installation is complete, the app restarts and an updated version opens. In this case, it is recommended to display an additional dialogue to allow the user to confirm explicitly that he or she is ready to relaunch app right now.

      该应用程序会启动安装过程,同时向用户显示Google Play屏幕并向用户显示安装进度。 安装完成后,该应用程序将重新启动并打开更新的版本。 在这种情况下,建议显示其他对话框,以允许用户明确确认他或她现在准备重新启动应用程序。

      这是一个强烈推荐的流程 (This is a highly-recommended flow)

      .

    2. The app waits until it goes to the background and then completes the update silently. One the one hand, this option is less invasive in terms of user experience. But on the other hand, it requires the developer to implement a tricky feature for detecting whenever the app goes to the background.

      该应用程序等待,直到它进入后台,然后以静默方式完成更新。 一方面,就用户体验而言,此选项的侵入性较小。 但另一方面,它要求开发人员实现一项棘手的功能,以检测应用程序何时进入后台。

In exceptional situations, the completion of the update will be deferred automatically to the Google Play background task. This option is not recommended for the explicit use because it doesn’t provide any guarantees about the installation of an update.

在特殊情况下,更新的完成将自动推迟到Google Play后台任务。 不建议将该选项显式使用,因为它不提供有关安装更新的任何保证。

手动测试的基本要求 (Basic Requirements for Manual Testing)

In order to manually perform the full update flow on the test device, you should have at least two versions of the app with the different version number: a source version and a target version.

为了在测试设备上手动执行完整的更新流程,您应至少拥有两个版本的应用程序,且版本号不同:源版本和目标版本。

  • The source version with the higher version number should be published at Google Play, this is the version which will be identified by Google Play as an available update. The target version with the lower version number and integrated IAUs feature should be installed on your device, this is the version which will be updated. The thing is, when the app requests Google Play to check for available updates, it compares the version number of the installed app with the version number of the last available build in Google Play. So the IAUs feature will be triggered only in case if the version number in Google Play is higher than actual version of the app on the device.

    具有较高版本号的源版本应在Google Play上发布,这是Google Play会将其标识为可用更新的版本。 具有较低版本号和集成IAU功能的目标版本应安装在您的设备上,这是将更新的版本。 问题是,当应用程序请求Google Play检查可用更新时,它会将安装的应用程序的版本号与Google Play中最后一个可用版本的版本号进行比较。 因此,只有在Google Play中的版本号高于设备上应用程序的实际版本的情况下,才会触发IAUs功能。

  • Both the source and the target versions need to have the

    源版本和目标版本都需要具有

    相同的包装名称 (same package name)

    and should be signed with the

    并应与

    相同的发行证书 (same release certificate)

    .

  • Android 5.0 (API level 21) or higher.

    Android 5.0(API级别21)或更高版本。

  • Play Core library 1.5.0 or higher.

    播放Core库1.5.0或更高版本。

样例代码 (Sample Code )

This section contains some sample code for IAUs usage, which is also can be found in the official documentation. To begin with, it’s necessary to add Play Core library to the module-level gradle file.

本节包含一些有关IAU用法的示例代码,也可以在官方文档中找到。 首先,必须将Play Core库添加到模块级gradle文件。

dependencies {
   ...
   implementation "com.google.android.play:core:1.5.0"
}

Next, let’s create an instance of the IAUs manager and add callbacks to AppUpdateInfo task. The result of this task contains information about an update availability, an intent to start an update if it is available, and the current progress of the update download if it has already started.

接下来,让我们创建IAUs管理器的实例,并将回调添加到AppUpdateInfo任务。 该任务的结果包含有关更新可用性的信息,启动更新的意图(如果可用)以及更新下载的当前进度(如果已经启动)。

// Create instance of the IAUs manager.
val appUpdateManager = AppUpdateManagerFactory.create(context)

// Add state listener to app update info task.
appUpdateManager.appUpdateInfo.addOnSuccessListener { appUpdateInfo ->
    // If there is an update available, prepare to promote it.
    if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
        // ...
    }

    // If the process of downloading is finished, start the completion flow.
    if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
        // ...
    }
}
    .addOnFailureListener { e ->
        // Handle the error.
    }

In terms of how to trigger the update request dialogue from Google Play in code, you receive a PendingIntent in the AppUpdateInfo object, which you can start with startIntentSenderForResult. This dialogue requests the user to start the update.

就如何通过代码触发来自Google Play的更新请求对话而言,您会在AppUpdateInfo对象中收到PendingIntent ,可以从startIntentSenderForResult开始。 此对话框要求用户开始更新。

appUpdateManager.startUpdateFlowForResult(
          // Pass the intent that is returned by 'getAppUpdateInfo()'.
           appUpdateInfo,
           // Or 'AppUpdateType.IMMEDIATE for immediate updates.
           AppUpdateType.FLEXIBLE,
          // The current activity.
           activity,
           REQUEST_CODE
   )

To monitor the update state, you can add InstallStateUpdatedListener to the IAUs manager. Please make sure your InstallStateUpdatedListener is lifecycle-aware.

要监视更新状态,可以将InstallStateUpdatedListener添加到IAUs管理器中。 请确保您的InstallStateUpdatedListener生命周期。

// Create a listener to track downloading state updates.
val listener = InstallStateUpdatedListener { state -> 
    // Update progress indicator, request user to approve app reload, etc.
}

// At some point before starting an update, register a listener for updates.
appUpdateManager.registerListener(listener)

// ...

// At some point when status updates are no longer needed, unregister the listener.
appUpdateManager.unregisterListener(listener)

As soon as the update is downloaded (DOWNLOADED status), the app should be restarted in order to complete the update. It can be easily initiated by calling appUpdateManager.completeUpdate(), but it’s recommended to display a snackbar to allow the user to confirm explicitly that he or she is ready to relaunch app right now.

一旦下载了更新(“已DOWNLOADED状态),应重新启动应用程序以完成更新。 可以通过调用appUpdateManager.completeUpdate()轻松启动它,但是建议显示一个小吃栏,以允许用户明确确认他或她现在准备重新启动应用程序。

Snackbar.make(
    rootView,
    "An update has just been downloaded from Google Play",
    Snackbar.LENGTH_INDEFINITE
).apply {
    setAction("RELOAD") { appUpdateManager.completeUpdate() }
    show()
}

«更新不可用»错误 («Update is Not Available» Error)

First of all, please double check requirements mentioned in «Basic Implementation Requirements» section. If you successfully complete above listed steps in compliance with all requirements, though the update, according to the onSuccess callback, still is not available, please pay attention to the following trick. The most likely reason is that the Google Play app does not know about the update yet due to the internal caching mechanism. To make sure you have the cache fresh when testing manually you can refresh the cached version by going to the «My Apps & Games» screen in the Google Play app. As an alternative, you can simply clear the cache of the Google Play app in the settings. Note that this is just an issue for testing and does not affect end users since the cache is updated daily anyway.

首先,请仔细检查“基本实施要求”部分中提到的要求。 如果您按照所有要求成功完成了上面列出的步骤,尽管根据onSuccess回调仍然无法进行更新,请注意以下技巧。 最可能的原因是由于内部缓存机制,Google Play应用尚不知道该更新。 为确保在手动测试时拥有最新的缓存,您可以通过转到Google Play应用中的“我的应用和游戏”屏幕来刷新缓存的版本。 另外,您也可以在设置中清除Google Play应用的缓存。 请注意,这只是测试问题,不会影响最终用户,因为无论如何缓存都是每天更新的。

盘岛的IAU灵活流动 (IAUs Flexible Flow in Pandao)

As a part of early access program, we integrated IAUs flexible flow (recommended implemetation) in Pandao app, that is, a marketplace app offering products from Chinese manufacturers and vendors. The IAUs dialogue was shown at the main screen, so the maximum number of users were able to interact with it. Initially, we decided to show IAUs dialogue not more than once a day in order to avoid risk users being annoyed.

作为早期访问计划的一部分,我们将IAU的灵活流程(推荐实现)集成到了盘岛应用程序中,该应用程序提供了来自中国制造商和供应商的产品。 IAU对话框显示在主屏幕上,因此可以与之进行交互的最大用户数。 最初,我们决定每天向IAU进行不超过一次的对话,以免使用户感到烦恼。

Since A/B testing is a pivotal step in every new feature lifecycle, we decided to evaluate the effect of IAUs on the Pandao app. We randomly divided our users into two non-overlapping groups. The first one is a control group without IAUs functional representing the ‘no-change’ baseline, and the second one is a test group with IAUs dialogue.

由于A / B测试是每个新功能生命周期中的关键步骤,因此我们决定评估IAU对Pandao应用程序的影响。 我们将用户随机分为两个不重叠的组。 第一个是没有IAU功能的对照组代表“不变”基线,第二个是带有IAU对话的测试组。

Fig. 1. A/B testing for IAUs (flexible flow) in Pandao App. 图1. Pandao App中的IAU(灵活流)的A / B测试。

Over the past few releases, we measured the percentage of active users for each app version. It was found that among active users with the last available at a time version the major part was from group B, i.e. users with IAUS feature. As you can see from purple lines at fig. 1, in the first days after the publication of 1.29.1 app version, the number of active users with IAUs feature exceeded the number of users without this feature. The opposite situation can be observed for the previous versions of the app, see blue and red lines after the publication of 1.29.1 app version. Therefore, it can be stated that users with IAUs tend to update the app version more quickly.

在过去的几个版本中,我们测量了每个应用程序版本的活跃用户百分比。 发现在最新版本的可用用户中,主要用户来自B组,即具有IAUS功能的用户。 从图的紫色线条可以看到。 如图1所示,在发布1.29.1应用程序版本后的头几天,具有IAU功能的活动用户数超过了不具有此功能的用户数。 对于该应用程序的先前版本,可以观察到相反的情况,在发布1.29.1应用程序版本后,请参见蓝色和红色线条。 因此,可以说具有IAU的用户倾向于更快地更新应用程序版本。

Fig. 2. Confirmation rate at IAUs dialogue (flexible flow) in Pandao App. 图2.盘岛App中IAU对话(灵活流程)的确认率

According to Pandao analytics data (see fig. 2), conversion to click on the confirmation button at IAUs dialogue reaches peak values at the first days of the release and then constantly decreases until the next app update. The same pattern can be observed in conversion to click on the install button at a snackbar, which initiates installation of the downloaded update. Consequently, it seems like the average conversion rate in both cases directly proportional to the frequency of releases. In Pandao, the average conversion rate measured during one month exceeds 35% for click on the confirmation button and 7% for click on the install button.

根据Pandao分析数据(参见图2),在IAU对话中单击确认按钮的转换在发布的第一天达到峰值,然后不断下降,直到下一次应用程序更新。 转换为在小吃店单击安装按钮后,可以观察到相同的模式,这将启动安装下载的更新。 因此,这两种情况下的平均转化率似乎都与释放频率成正比。 在盘岛,一个月内测得的平均转换率超过35%(单击确认按钮)和7%(单击安装按钮)。

We suggested that reducing of confirmation rate over time is just a user experience problem, because people that are interested in the new app version are going to update pretty quickly, and those that are not interested in updating will continue to not be interested. Based on this information we decided backing off some users if they are not interested in updating, rather than asking them every day. It seems to be a good practice trying different request logic based on 'staleness', i.e. how old the version they are on is, how many times a user has already asked them for an update and so on, rather than risk users being annoyed.

我们建议随着时间的推移降低确认率只是用户体验问题,因为对新应用版本感兴趣的人将很快更新,而对更新不感兴趣的人将继续不感兴趣。 根据这些信息,我们决定退回某些用户是否对更新不感兴趣,而不是每天询问他们。 尝试基于“陈旧性”尝试不同的请求逻辑(这是他们使用的版本多大,用户已经要求他们进行更新的次数等等)似乎是一种好习惯,而不必冒使用户烦恼的风险。

As a result, IAUs demonstrated valuable results during A/B test, so we rolled out this feature for all users.

结果,IAU在A / B测试期间展示了有价值的结果,因此我们为所有用户推出了此功能。

致谢 (Acknowledgments)

I want to thank various colleagues for their contribution to this article. Thanks to Maryna Pliashkova Maryna_Pliashkova, Alexander Chernyy alexchernyy, Ilia Nazarov RolaRko, Gleb Bodyachevskiy, Daniil Polozov jokerdab, Anastasia Kulik, Vladislav Breus and Vladislav Goldin Vladiskus.

我要感谢各个同事对本文的贡献。 感谢Maryna Pliashkova Maryna_Pliashkova ,Alexander Chernyy alexchernyy ,Ilia Nazarov RolaRko ,Gleb Bodyachevskiy,Daniil Polozov jokerdab ,Anastasia Kulik,Vladislav Breus和Vladislav Goldin Vladiskus

翻译自: https://habr.com/en/company/mailru/blog/452082/

android 应用内更新

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值