Skip to content

Instantly share code, notes, and snippets.

@kayahanbaskeser
Created March 18, 2021 14:49
Show Gist options
  • Save kayahanbaskeser/6dc4958c3ea8df844e0b864aa38d5876 to your computer and use it in GitHub Desktop.
Save kayahanbaskeser/6dc4958c3ea8df844e0b864aa38d5876 to your computer and use it in GitHub Desktop.
CheckIapAvailability update
public void CheckIapAvailability()
{
iapClient = Iap.GetIapClient();
ITask<EnvReadyResult> task = iapClient.EnvReady;
task.AddOnSuccessListener((result) =>
{
Debug.Log($"{TAG}: checkIapAvailabity SUCCESS");
iapAvailable = true;
OnCheckIapAvailabilitySuccess?.Invoke();
}).AddOnFailureListener(exception =>
{
Debug.Log($"{TAG}: Error on checkIapAvailabity");
IapApiException iapApiException = exception.AsIapApiException();
Status status = iapApiException.Status;
if (status.HasResolution())
{
status.StartResolutionForResult(
intent => {
iapAvailable = true;
Debug.Log($"{TAG}: checkIapAvailabity SUCCESS");
OnCheckIapAvailabilitySuccess?.Invoke();
},
ex =>
{
Debug.Log($"{TAG}: Error on checkIapAvailabity2");
iapClient = null;
iapAvailable = false;
OnCheckIapAvailabilityFailure?.Invoke(exception);
});
} else
{
Debug.Log($"{TAG}: Error on checkIapAvailabity3");
iapClient = null;
iapAvailable = false;
OnCheckIapAvailabilityFailure?.Invoke(exception);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment