private void InitiateRequest(AppUpdateRequestImpl request, AppUpdateInfo appUpdateInfo, AppUpdateOptions appUpdateOptions) { if (appUpdateInfo.UpdateAvailability == UpdateAvailability.DeveloperTriggeredUpdateInProgress) { // If an update is already in progress, it would skip user confirmation dialog and // the ActivityResult for user confirmation should be set to ResultOk. request.SetUpdateActivityResult(ActivityResult.ResultOk); } if (request.IsDone && appUpdateOptions.AppUpdateType == AppUpdateType.Flexible) { request.OnUpdateDownloaded(); } else { var requestFlowTask = _appUpdateManagerPlayCore.StartUpdateFlow(appUpdateInfo, appUpdateOptions); requestFlowTask.RegisterOnSuccessCallback(resultCode => { // Set user confirmation dialog result for the update request. request.SetUpdateActivityResult(resultCode); requestFlowTask.Dispose(); }); requestFlowTask.RegisterOnFailureCallback((reason, errorCode) => { Debug.LogErrorFormat("Update flow request failed: {0}", errorCode); request.OnErrorOccurred(AppUpdatePlayCoreTranslator.TranslatePlayCoreErrorCode(errorCode)); requestFlowTask.Dispose(); }); } }
private void AppUpdateRequest(AppUpdateRequestImpl request, AppUpdateState newState) { if (AppUpdatePlayCoreTranslator.TranslatePlayCoreErrorCode(newState.ErrorCode) != AppUpdateErrorCode.NoError) { request.OnErrorOccurred(request.Error); return; } request.UpdateState(AppUpdatePlayCoreTranslator.TranslatePlayCoreUpdateStatus(newState.Status), newState.BytesDownloaded, newState.TotalBytesToDownload); }
/// <summary> /// Creates an <see cref="AppUpdateRequest"/> that can be used to monitor the update progress and start the /// desired update flow indicated by <see cref="appUpdateOptions"/>. /// </summary> /// <param name="appUpdateInfo">The on success result of <see cref="GetAppUpdateInfo"/>.</param> /// <param name="appUpdateOptions"><see cref="AppUpdateOptions"/> contains update type options.</param> /// <returns> /// A <see cref="AppUpdateRequest"/> which can be used to monitor the asynchronous request of an update flow. /// </returns> /// <exception cref="ArgumentNullException"> /// Throws if any of the the provided parameters are null. /// </exception> /// <exception cref="InvalidOperationException"> /// Throws if there is already an <see cref="AppUpdateRequest"/> in progress. /// </exception> public AppUpdateRequest StartUpdateInternal(AppUpdateInfo appUpdateInfo, AppUpdateOptions appUpdateOptions) { if (appUpdateInfo == null) { throw new ArgumentNullException("appUpdateInfo"); } if (appUpdateOptions == null) { throw new ArgumentNullException("appUpdateOptions"); } if (_appUpdateRequest != null) { throw new InvalidOperationException( "Another update flow is already in progress."); } _appUpdateRequest = new AppUpdateRequestImpl(); if (appUpdateInfo.UpdateAvailability == UpdateAvailability.UpdateNotAvailable) { _appUpdateRequest.OnErrorOccurred(AppUpdateErrorCode.ErrorUpdateUnavailable); return(_appUpdateRequest); } if (!appUpdateInfo.IsUpdateTypeAllowed(appUpdateOptions)) { _appUpdateRequest.OnErrorOccurred(AppUpdateErrorCode.ErrorUpdateNotAllowed); return(_appUpdateRequest); } _appUpdateRequest.Completed += (req) => { _appUpdateRequest = null; }; InitiateRequest(_appUpdateRequest, appUpdateInfo, appUpdateOptions); return(_appUpdateRequest); }