如何设置新Android版本的更新优先级

z3yyvxxp  于 2022-11-27  发布在  Android
关注(0)|答案(7)|浏览(164)

我一直在尝试实现谷歌新的应用内更新,但我在一个点上卡住了。问题首先是,开发人员如何在发布应用新更新时指定更新类型,即灵活或即时。其次,如果是由开发人员来决定他必须为特定更新实现哪种类型的更新,那么- appUpdateInfo.isUpdateTypeAllowed有什么用(应用程序更新类型.IMMEDIATE)或应用程序更新信息.isUpdateTypeAllowed(应用程序更新类型.Flexible)
文档中给出了**Google Play使用0到5之间的整数值,0为默认值,5为最高优先级。要设置更新的优先级,请使用Google Play开发者API中Edits.tracks.releases下的inAppUpdatePriority字段。**如何设置?

qoefvg9y

qoefvg9y1#

可以使用Play开发者发布API的编辑方法来设置应用更新的优先级。目前还没有办法使用Play控制台来设置它,但有一个计划集成在Play控制台中。请查看此以获得更多帮助,您还可以在此链接中找到其他有用的说明。希望它能对您有所帮助

yc0p9oo0

yc0p9oo02#

在应用程序更新中使用Firebase远程配置和Android的组合似乎效果不错。
请参考此处的教程:https://engineering.q42.nl/android-in-app-updates/

643ylb08

643ylb083#

这里是谷歌官方指南https://developers.google.com/android-publisher/api-ref/rest/v3/edits.tracks/update
但我不知道如何运行API。
参数“editId”和“track”是什么?“授权范围”是什么?
Google确实需要提高他们文档编制技能,以便让像我们这样的开发人员能够清楚地了解它,

8cdiaqws

8cdiaqws4#

我可以推荐https://github.com/Triple-T/gradle-play-publisher
然后你就可以把你的优先权放在你的Gradle里了。

play {
 // Overrides defaults
 track.set("production")
 userFraction.set(0.5)
 updatePriority.set(2)
 releaseStatus.set(ReleaseStatus.IN_PROGRESS)
}
qzlgjiam

qzlgjiam5#

我解释了如何将inAppUpdatePriority设置为5。
1.创建内部发布,但不将其部署到内部测试人员。因此,其状态为草稿。
1.按照以下说明安装Google API客户端库for Python:https://github.com/googlesamples/android-play-publisher-api/tree/master/v3/python
1.使用以下代码并根据需要进行编辑:

import argparse
import sys
from apiclient import sample_tools
from oauth2client import client
import json

TRACK = 'internal'

# Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument('package_name',
                       help='The package name. Example: com.android.sample')

def main(argv):
  # Authenticate and construct service.
  service, flags = sample_tools.init(
      argv,
      'androidpublisher',
      'v3',
      __doc__,
      __file__,
      parents=[argparser],
      scope='https://www.googleapis.com/auth/androidpublisher')

  # Process flags and read their values.
  package_name = flags.package_name

  try:

    edit_request = service.edits().insert(body={}, packageName=package_name)
    result = edit_request.execute()
    edit_id = result['id']

    tracks_result = service.edits().tracks().list(
        editId=edit_id, packageName=package_name).execute()
    
    track_release = None
    for release in tracks_result["tracks"]:
      if release["track"] == TRACK:
        track_release = release
    
    release_data = track_release["releases"][0]
    release_data["inAppUpdatePriority"] = 5
    track_response = service.edits().tracks().update(
        editId=edit_id,
        track=TRACK,
        packageName=package_name,
        body={u'releases': [release_data]}).execute()
    print(json.dumps(track_response,sort_keys=True, indent=2))

    commit_request = service.edits().commit(
        editId=edit_id, packageName=package_name).execute()

  except client.AccessTokenRefreshError:
    print ('The credentials have been revoked or expired, please re-run the '
           'application to re-authorize')

if __name__ == '__main__':
  main(sys.argv)

您应该将其保存为filename.py
1.在安装所有依赖项并赋予所需权限后,启动它(com.android.sample是您的包名):

python filename.py com.android.sample
ojsjcaue

ojsjcaue6#

使用版本代码,可以决定是否进行更新。例如:版本号为偶数强制更新,为奇数灵活更新。

agxfikkp

agxfikkp7#

Warning This method only works out if you have not start rollout to production of the updated version code bundle
I found a way for doing it manually
Step 1. Generate a access Toekn Key for your account by following this tutorial
https://codeible.com/view/videotutorial/EUVd83616z4AppnnKk4Y;title=Generating%20the%20JWT%20and%20Retrieving%20the%20OAuth%202.0%20Token
Step 2. Copy the access token The access token will be of this type
"ya29.c.b0AUFJQsGvVWO8VYxKHVlS-VzF-A4f5RvwIhXww8xYq6TAB-oCgMTOoDPG9pgQGjfXe-nNogus5q1fjovSB1mNeNTIPFXCq4Hfd3pUZEuYrNoyB3bf-twLIMdV-p_c7vAv_aAfjHUzKdKXSlFSrV1_Gdi-TEnoV-RnOEqKA3szGTGMRfWx2GCR34MuhAxUJFVUl7h4V7r8ad3gXMjYh912IPzEfec4G0o........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................", copy this for authorization
Step 3. Do a POST Request on Postman of the following url
https://androidpublisher.googleapis.com/androidpublisher/v3/applications/your_package_name/edits
See image for how to set up header for authorization
https://i.stack.imgur.com/06TxY.png
Step 4. Do a PUT Requestion on Postman of the following url and copy the edit number generated from step 3
https://androidpublisher.googleapis.com/androidpublisher/v3/applications/packagename/edits/generated_edit_number/tracks/production
See image for how to set up body for specifying the version code and update priority and put same heaader as done in step-3
https://i.stack.imgur.com/VpH1w.png
Step 5. Finally do a POST Request of the following url with the same headers as
mentioned in step 3
https://androidpublisher.googleapis.com/androidpublisher/v3/applications/packagename/edits/generated_edit_number:commit

相关问题