Hi everyone,
I’m currently trying to implement an immediate in-app update feature in my Unity game using Google Play’s In-App Update API, but I’m facing a problem with converting AppUpdateType to AppUpdateOptions. Here’s the specific error I’m getting:
Error (CS1503): Argument 1: cannot convert from 'Google.Play.AppUpdate.AppUpdateType' to 'Google.Play.AppUpdate.AppUpdateOptions'
Context:
I want to use the immediate update flow (no priority handling is needed). I’m following the documentation provided here, and here’s a simplified version of my code:
Code Example:
using System.Collections;
using UnityEngine;
using Google.Play.AppUpdate;
using Google.Play.Common;
public class InAppUpdateManager : MonoBehaviour
{
AppUpdateManager appUpdateManager = new AppUpdateManager();
private void Start()
{
StartCoroutine(CheckForUpdate());
}
IEnumerator CheckForUpdate()
{
PlayAsyncOperation<AppUpdateInfo, AppUpdateErrorCode> appUpdateInfoOperation = appUpdateManager.GetAppUpdateInfo();
yield return appUpdateInfoOperation;
if (appUpdateInfoOperation.IsSuccessful)
{
var appUpdateInfo = appUpdateInfoOperation.GetResult();
// Create update options for immediate update
var appUpdateOptions = AppUpdateOptions.ImmediateAppUpdateOptions();
// Attempt to start the update
var appUpdateRequest = appUpdateManager.StartUpdate(appUpdateInfo, appUpdateOptions);
yield return appUpdateRequest;
}
else
{
Debug.LogError("Error fetching update info: " + appUpdateInfoOperation.Error);
}
}
}
Problem:
The issue happens when I try to start the update using appUpdateManager.StartUpdate(appUpdateInfo, appUpdateOptions); — it gives the error I mentioned above (CS1503). I’m using the immediate update type with the AppUpdateOptions.ImmediateAppUpdateOptions() method, as suggested in the documentation.
What I’ve Tried:
- Ensuring that the namespaces
Google.Play.AppUpdateandGoogle.Play.Commonare included. - I’ve checked if the
AppUpdateManageris properly initialized.
Unity Version:
- Unity 2022.3.41f1 LTS
- Play Core plugin version: 2.1.0
Questions:
- Why does this error occur when I try to use
AppUpdateOptions? - Is there a specific way I need to configure or pass the options for an immediate update?
- How can I fix the error and properly initiate the immediate in-app update?
- If possible please provide me a updated script or resource .
Thanks in advance for any help or guidance!