I would like to ask about forcing users to update the game from Google Play. I have created a game that can be played offline. The game is about scoring points, breaking records, and upgrades. As I mentioned, the game can be played offline, but there is an online ranking where you can compare your records. It will also be possible to log in with a Google account or create an account so that when you log in on another device, all your progress in the game will be transferred. This is similar to Subway Surfers.
I would like Google Play (and in the future also the App Store) to force users to update the game. How can this be solved? The ranking database is located in Firebase.
Google Play won’t directly force any update on anybody that doesn’t want it. That’s not how they do things. They will inform the user that an app can be updated if they go into the Apps section of their configuration or look on their Google Play dashboard.
You can force an update through code, but there are a couple of steps you’ll need to do:
You’ll need to add the Google Play Core Plugin found at this Github repository: GitHub - google/play-core-unity. You can add this via the Package Manager with install from git url and typing in the url for the repository.
From there, you’ll need to check to see if there is an update available in the Play Store using the API provided in that Github.
Here’s a sample script using that plugin. Note: This is a third party solution, I’m just passing it through after researching the issue. For further assistance, you’ll need to contact the providers of the utiltity
using Google.Play.AppUpdate;
using Google.Play.Common;
using UnityEngine;
using System.Collections;
public class UpdateManager : MonoBehaviour
{
private AppUpdateManager appUpdateManager;
void Start()
{
appUpdateManager = new AppUpdateManager();
StartCoroutine(CheckForUpdate());
}
IEnumerator CheckForUpdate()
{
// Check for updates
PlayAsyncOperation<AppUpdateInfo, AppUpdateErrorCode> appUpdateInfoOperation =
appUpdateManager.GetAppUpdateInfo();
// Wait until the operation completes
yield return appUpdateInfoOperation;
if (appUpdateInfoOperation.IsSuccessful)
{
var appUpdateInfoResult = appUpdateInfoOperation.GetResult();
// Check if update is available
if (appUpdateInfoResult.UpdateAvailability == UpdateAvailability.UpdateAvailable)
{
// Start immediate update flow
var appUpdateOptions = AppUpdateOptions.ImmediateAppUpdateOptions();
StartCoroutine(StartImmediateUpdate(appUpdateInfoResult, appUpdateOptions));
}
}
else
{
Debug.LogError("Update check failed: " + appUpdateInfoOperation.Error);
}
}
IEnumerator StartImmediateUpdate(AppUpdateInfo appUpdateInfo, AppUpdateOptions appUpdateOptions)
{
var startUpdateRequest = appUpdateManager.StartUpdate(appUpdateInfo, appUpdateOptions);
yield return startUpdateRequest;
if (startUpdateRequest.IsSuccessful)
{
Debug.Log("Update started successfully");
}
else
{
Debug.LogError("Update failed: " + startUpdateRequest.Error);
}
}
}
The play console also has a not very advertised feature of prompting users to update your app on app launch (but doesn’t force them to update). Might be a good option for older releases that you don’t have a killswitch built into the app yet.