// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. using System; using Google.Play.AppUpdate.Internal; using Google.Play.Common; namespace Google.Play.AppUpdate { /// /// Manages operations for requesting and launching an in-app update flow. /// public class AppUpdateManager { private readonly AppUpdateManagerInternal _appUpdateManagerInternal; /// /// Constructor. /// public AppUpdateManager() { _appUpdateManagerInternal = new AppUpdateManagerInternal(); } /// /// Makes a network call to get in-app update information. This must be called before /// to obtain an , which is needed to start an update. /// /// /// A that returns /// on successful callback or on failure callback. /// public PlayAsyncOperation GetAppUpdateInfo() { return _appUpdateManagerInternal.GetAppUpdateInfoInternal(); } /// /// Starts an in-app update flow for the specified update type. Before calling this method use /// to get an object. /// /// The result of a successful call to . /// The type of update flow and additional options. /// /// An that can be used to monitor the requested in-app update flow. /// /// Thrown if any parameter is null. public AppUpdateRequest StartUpdate(AppUpdateInfo appUpdateInfo, AppUpdateOptions appUpdateOptions) { return _appUpdateManagerInternal.StartUpdateInternal(appUpdateInfo, appUpdateOptions); } /// /// Asynchronously requests to complete a flexible in-app update flow that was started via /// . This should be called after the /// succeeds. After calling this function the system installer will close the app, /// perform the update, and then restart the app at the updated version. /// /// /// A that returns an /// on failure. /// If the update succeeds, the app restarts and this callback should never fire. /// public PlayAsyncOperation CompleteUpdate() { return _appUpdateManagerInternal.CompleteUpdateInternal(); } } }