0

I implement In-App Update feature in my android application but it not working untill i go to playstore app and view update button. Please suggest me some solution. Thanks

   public void ImmidateUpdate()
    {

        AppUpdateManager appUpdateManager = AppUpdateManagerFactory.create(getActivity());

// Returns an intent object that you use to check for an update.
        Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();

// Checks that the platform will allow the specified type of update.
        appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
            if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE)
            {
                if(appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE))
                {
                    try {
                        appUpdateManager.startUpdateFlowForResult(
                                // Pass the intent that is returned by 'getAppUpdateInfo()'.
                                appUpdateInfo,
                                // Or 'AppUpdateType.FLEXIBLE' for flexible updates.
                                AppUpdateType.IMMEDIATE,
                                // The current activity making the update request.
                                getActivity(),
                                // Include a request code to later monitor this update request.
                                1210);
                    } catch (IntentSender.SendIntentException e) {
                        e.printStackTrace();
                    }
                }

            }
        });

    }
a_local_nobody
  • 7,947
  • 5
  • 29
  • 51

1 Answers1

0

Set the priority using the Google Play Developer API as described in the Play Developer API documentation. In-app update priority should be specified in the Edit.tracks resource passed in the Edit.tracks: update method.

please refer to the documntation

Omar Mahmoud
  • 2,902
  • 1
  • 14
  • 22
  • How to set this one. { "releases": [{ "versionCodes": ["88"], "inAppUpdatePriority": 5, "status": "completed" }] } – Zeeshan Ashraf Aug 30 '21 at 12:01
  • you need to use Play Developer API https://developers.google.com/android-publisher/api-ref/rest/v3/edits – Omar Mahmoud Aug 30 '21 at 12:08
  • How i authenticate my request. I am getting this response { "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" } } – Zeeshan Ashraf Aug 30 '21 at 12:56
  • I am Using this one https://developers.google.com/android-publisher/api-ref/rest/v3/edits.tracks/update – Zeeshan Ashraf Aug 30 '21 at 13:23
  • { "error": { "code": 403, "message": "The project id used to call the Google Play Developer API has not been linked in the Google Play Developer Console.", "status": "PERMISSION_DENIED" } } – Zeeshan Ashraf Aug 30 '21 at 13:37
  • this may help you https://stackoverflow.com/questions/25481207/error-the-project-id-used-to-call-the-google-play-developer-api-has-not-been-l – Omar Mahmoud Aug 30 '21 at 14:12