44

I have been trying to implement the Google’s new in-app updates and I am stuck at a point. The issue is first, how can the developer specify the type of update i.e. flexible or immediate while releasing a new update of the app. Secondly, if it's for the developer to decide which type of update he has to implement for a specific update then what is the use of – appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE) or appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.Flexible)

it is given in the documentation that Google Play uses an integer value between 0 and 5, with 0 being the default, and 5 being the highest priority. To set the priority for an update, use inAppUpdatePriority field under Edits.tracks.releases in the Google Play Developer API. how to set it?

abhijith em
  • 461
  • 1
  • 4
  • 6

7 Answers7

27

Priority for app update can be set using Play Developer Publishing API's ⁠Edits methods. Currently there is no way to set it using Play Console but there is a plan to integrate in Play Console. Please look at this for more help, you will also find other helpful notes in this link. Hope it may help you

MrinmoyMk
  • 551
  • 7
  • 21
7

Using the combination of Firebase remote config and Android in app update seems to work well.

Please follow the tutorial here for reference : https://engineering.q42.nl/android-in-app-updates/

Sujith Chandran
  • 2,671
  • 1
  • 15
  • 13
7

Here is the Google official guides https://developers.google.com/android-publisher/api-ref/rest/v3/edits.tracks/update

But i don't know how to run the API.

What are the parameters "editId" & "track" ? And what is the "Authorization Scopes" ?

Google really need to improve their documentation skills to make it crystal clear for developer like us

enter image description here

Ashraf Amin
  • 343
  • 3
  • 7
4

I can recommend the https://github.com/Triple-T/gradle-play-publisher

Then you can set your prio in your gradle.

play {
 // Overrides defaults
 track.set("production")
 userFraction.set(0.5)
 updatePriority.set(2)
 releaseStatus.set(ReleaseStatus.IN_PROGRESS)
}
kuzdu
  • 7,124
  • 1
  • 51
  • 69
  • Its easy with `gradle-play-publisher` library – Abu Yousuf Sep 21 '21 at 06:55
  • How do you preserve the updatePriority while promoting a track? It seems to be gone after promotion and resetted to 0. – JuToGe Sep 08 '22 at 09:28
  • I would recommend to use a CI/CD There you could set an environment variable. If you don't use a CI/CD use just environment variables in gradle. Or you could read the config from a .txt or .csv file – kuzdu Sep 11 '22 at 08:17
1

Using the version code, a decision can be made about the update. Example: forced update if version code is even number, flexible update if odd number.

  • 3
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 19 '22 at 10:20
  • Solves the problem for while. Good idea – Gilian Mar 05 '23 at 06:32
1

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

Kunal Mathur
  • 59
  • 1
  • 3
0

I explain how I was able to set inAppUpdatePriority to 5.

  1. Create an internal release without deploying it to internal testers. Thus, its status is draft.
  2. Install the Google APIs Client Library for Python as explained here: https://github.com/googlesamples/android-play-publisher-api/tree/master/v3/python
  3. Use the following code and edit it to match your need:
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)

You should save it an filename.py.

  1. After installing all dependencies and giving required permissions, launch it as (com.android.sample is your package name):
python filename.py com.android.sample