반응형
SDK 다운로드
코드 작성
#if UNITY_ANDROID
using Google.Play.AppUpdate;
using Google.Play.Common;
#endif
#if UNITY_ANDROID
IEnumerator CheckForUpdate()
{
yield return new WaitForSeconds(0.5f);
AppUpdateManager appUpdateManager = new AppUpdateManager();
PlayAsyncOperation<AppUpdateInfo, AppUpdateErrorCode> appUpdateInfoOperation = appUpdateManager.GetAppUpdateInfo();
yield return appUpdateInfoOperation; //업데이트 가능한지 체크 중
if (appUpdateInfoOperation.IsSuccessful)
{
var appUpdateInfoResult = appUpdateInfoOperation.GetResult();
if(appUpdateInfoResult.UpdateAvailability == UpdateAvailability.UpdateAvailable)
{
var appUpdateOptions = AppUpdateOptions.ImmediateAppUpdateOptions();
var startUpdateRequest = appUpdateManager.StartUpdate(appUpdateInfoResult,appUpdateOptions);
while(!startUpdateRequest.IsDone)
{
if(startUpdateRequest.Status == AppUpdateStatus.Downloading)
{
Debug.Log("업데이트 다운로드 진행중");
}
else if(startUpdateRequest.Status == AppUpdateStatus.Downloaded)
{
Debug.Log("다운로드가 완료");
}
yield return null;
}
var result = appUpdateManager.CompleteUpdate();
while(!result.IsDone)
{
yield return new WaitForEndOfFrame();
}
yield return (int)startUpdateRequest.Status;
}
else if(appUpdateInfoResult.UpdateAvailability == UpdateAvailability.UpdateNotAvailable)
{
Debug.Log("업데이트가 없습니다");
}
}
else
{
Debug.Log("업데이트 에러");
}
}
#endif
Proguard 사용시
-keep class com.google.android.play.core.** { *; }
인앱 업데이트 설명서
반응형