//Updating a Saved Game public void UpdateSavedGame(String archiveID, ArchiveSummaryUpdate archiveSummaryUpdate, ArchiveDetails archiveContents) { String archiveId = archiveID; ITask <OperationResult> taskUpdateArchive = Games.GetArchiveClient().UpdateArchive(archiveId, archiveSummaryUpdate, archiveContents); taskUpdateArchive.AddOnSuccessListener((archiveDataOrConflict) => { Debug.Log("[HMS:] taskUpdateArchive" + archiveDataOrConflict.Difference); Debug.Log("isDifference:" + ((archiveDataOrConflict == null) ? "" : archiveDataOrConflict.Difference.ToString())); }).AddOnFailureListener((exception) => { }); }
//To obtain the archive cover, call ArchiveSummary.hasThumbnail to check whether there is a cover thumbnail. //If so, call ArchivesClient.getThumbnail to obtain the thumbnail data. public void LoadThumbnail(Archive archive) { if (archive.Summary.HasThumbnail()) { ITask <AndroidBitmap> coverImageTask = Games.GetArchiveClient(HuaweiId).GetThumbnail(archive.Summary.Id); coverImageTask.AddOnSuccessListener((result) => { Debug.Log("[HMS:] AndroidBitmap put it UI"); }).AddOnFailureListener((exception) => { }); } }
private void checkIapAvailabity() { iapClient = Iap.GetIapClient(); ITask <EnvReadyResult> task = iapClient.EnvReady; task.AddOnSuccessListener((result) => { Debug.Log("HMSP: checkIapAvailabity SUCCESS"); InitIAP(); }).AddOnFailureListener((exception) => { Debug.Log("HMSP: Error on ObtainOwnedPurchases"); if (IapApiExceptionUtils.IsIapApiException(exception)) { IapApiException iapApiException = IapApiExceptionUtils.AsIapApiException((exception)); Status status = iapApiException.Status; if (status.StatusCode == OrderStatusCode.ORDER_HWID_NOT_LOGIN) { // User not logged in if (status.HasResolution()) { status.StartResolutionForResult((androidIntent) => { Debug.Log("[HMS]: IAP login intent launched"); ITask <AuthHuaweiId> authTask = HuaweiIdAuthManager.ParseAuthResultFromIntent(androidIntent); authTask.AddOnSuccessListener((result) => { Debug.Log("[HMS]: IAP logged in user:"******"[HMS]: IAP user not logged:" + authException.Message); }); }, (statusException) => { Debug.Log("[HMS]: IAP login intent ERROR"); }); } } else if (status.StatusCode == OrderStatusCode.ORDER_ACCOUNT_AREA_NOT_SUPPORTED) { // The current region does not support HUAWEI IAP. Debug.Log("[HMS]: USer Area not supported by Huawei IAP"); } } }); }
public void GetAchievementsList() { ITask <IList <Achievement> > task = achievementsClient.GetAchievementList(true); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] GetAchievementsList SUCCESS"); OnGetAchievementsListSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSAchievementsManager]: GetAchievementsList failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnGetAchievementsListFailure?.Invoke(exception); }); }
public void GetAchievementsList() { ITask <IList <Achievement> > task = achievementsClient.GetAchievementList(true); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] GetAchievementsList SUCCESS"); OnGetAchievementsListSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.Log("[HMS GAMES] GetAchievementsList ERROR"); OnGetAchievementsListFailure?.Invoke(exception); }); }
public void GetLeaderboardData(string leaderboardId) { ITask <Ranking> task = rankingsClient.GetRankingSummary(leaderboardId, true); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] GetLeaderboardsData SUCCESS"); Debug.Log("[HMS GAMES] Received " + result.RankingDisplayName + "data"); }).AddOnFailureListener((exception) => { Debug.Log("[HMS GAMES] GetLeaderboardsData ERROR"); }); }
public void RevealAchievement(string achievementId) { ITask <HuaweiMobileServices.Utils.Void> task = achievementsClient.VisualizeWithResult(achievementId); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] RevealAchievement SUCCESS"); OnRevealAchievementSuccess?.Invoke(); }).AddOnFailureListener((exception) => { Debug.Log("[HMS GAMES] RevealAchievement ERROR"); OnRevealAchievementFailure?.Invoke(exception); }); }
public void SetUserScoreShownOnLeaderboards(int active) { ITask <int> task = rankingsClient.SetRankingSwitchStatus(active); task.AddOnSuccessListener((result) => { Debug.Log("[HMSLeaderboardManager] SetUserScoreShownOnLeaderboards SUCCESS" + result); OnSetUserScoreShownOnLeaderboardsSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSLeaderboardManager]: SetUserScoreShownOnLeaderboards failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnSetUserScoreShownOnLeaderboardsFailure?.Invoke(exception); }); }
public void GetLeaderboardData(string leaderboardId) { ITask <Ranking> task = rankingsClient.GetRankingSummary(leaderboardId, true); task.AddOnSuccessListener((result) => { Debug.Log("[HMSLeaderboardManager] GetLeaderboardsData SUCCESS"); OnGetLeaderboardDataSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSLeaderboardManager]: GetLeaderboardData failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnGetLeaderboardDataFailure?.Invoke(exception); }); }
public void SubmitScore(string leaderboardId, long score, string scoreTips) { ITask <ScoreSubmissionInfo> task = rankingsClient.SubmitScoreWithResult(leaderboardId, score, scoreTips); task.AddOnSuccessListener((scoreInfo) => { Debug.Log("[HMSLeaderboardManager] SubmitScore SUCCESS"); OnSubmitScoreSuccess?.Invoke(scoreInfo); }).AddOnFailureListener((error) => { Debug.LogError("[HMSLeaderboardManager]: SubmitScore failed. CauseMessage: " + error.WrappedCauseMessage + ", ExceptionMessage: " + error.WrappedExceptionMessage); OnSubmitScoreFailure?.Invoke(error); }); }
//Delete Saved Games public void DeleteSavedGames(ArchiveSummary archiveSummary) { // Deleting a Saved Games ITask <String> removeArchiveTask = Games.GetArchiveClient().RemoveArchive(archiveSummary); removeArchiveTask.AddOnSuccessListener((result) => { String deletedArchiveId = result; Debug.Log("[HMS:] deletedArchiveId" + result); }).AddOnFailureListener((exception) => { Debug.Log("[HMS:] removeArchiveTask" + exception.ErrorCode); }); }
public void RevealAchievement(string achievementId) { ITask <HuaweiMobileServices.Utils.Void> task = achievementsClient.VisualizeWithResult(achievementId); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] RevealAchievement SUCCESS"); OnRevealAchievementSuccess?.Invoke(); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSAchievementsManager]: RevealAchievement failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnRevealAchievementFailure?.Invoke(exception); }); }
public void SetStepAchievement(string achievementId, int stepsNum) { ITask <bool> task = achievementsClient.MakeStepsWithResult(achievementId, stepsNum); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] SetStepAchievement SUCCESS" + result); OnSetStepAchievementSuccess?.Invoke(); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSAchievementsManager]: SetStepAchievement failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnSetStepAchievementFailure?.Invoke(exception); }); }
public void SetUserScoreShownOnLeaderboards(int active) { ITask <int> task = rankingsClient.SetRankingSwitchStatus(1); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] SetUserScoreShownOnLeaderboards SUCCESS" + result); OnSetUserScoreShownOnLeaderboardsSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.Log("[HMS GAMES] SetUserScoreShownOnLeaderboards ERROR"); OnSetUserScoreShownOnLeaderboardsFailure?.Invoke(exception); }); }
public void SetStepAchievement(string achievementId, int stepsNum) { ITask <bool> task = achievementsClient.MakeStepsWithResult(achievementId, stepsNum); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] SetStepAchievement SUCCESS" + result); OnSetStepAchievementSuccess?.Invoke(); }).AddOnFailureListener((exception) => { Debug.Log("[HMS GAMES] SetStepAchievement ERROR"); OnSetStepAchievementFailure?.Invoke(exception); }); }
public void GetLeaderboardData(string leaderboardId) { ITask <Ranking> task = rankingsClient.GetRankingSummary(leaderboardId, true); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] GetLeaderboardsData SUCCESS"); OnGetLeaderboardDataSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.Log("[HMS GAMES] GetLeaderboardsData ERROR"); OnGetLeaderboardDataFailure?.Invoke(exception); }); }
public void SilentSignIn() { ITask <AuthAccount> taskAuthHuaweiId = authService.SilentSignIn(); taskAuthHuaweiId.AddOnSuccessListener((result) => { HuaweiId = result; OnSignInSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { HuaweiId = null; OnSignInFailed?.Invoke(exception); }); }
protected void InitIAP() { foreach (Product product in products) { if (product.isConsumable) { productIdConsumablesList.Add(product.productID); } } ProductInfoReq productInfoReq = new ProductInfoReq(); // CONSUMABLE REQUEST productInfoReq.PriceType = 0; productInfoReq.ProductIds = productIdConsumablesList; ITask <ProductInfoResult> task = iapClient.ObtainProductInfo(productInfoReq); Debug.Log(task.Result); task.AddOnSuccessListener((result) => { if (result != null) { if (result.ProductInfoList.Count != 0) { Debug.Log("[HMSPlugin]:" + result.ErrMsg + result.ReturnCode.ToString()); Debug.Log("[HMSPlugin]: Found " + result.ProductInfoList.Count + "consumable products"); foreach (ProductInfo productInfo in result.ProductInfoList) { Debug.Log("[HMSPlugin]: " + productInfo.ProductName + "," + productInfo.Price); productInfoList.Add(productInfo); } } } loadedEvent.Invoke(); }).AddOnFailureListener((exception) => { Debug.Log("[HMSPlugin]: ERROR Houston!!" + exception.Message); }); RestorePurchases(); ObtainOwnedPurchases(); }
public void GetScoresFromLeaderboard(string leaderboardId, int timeDimension, int maxResults, int offsetPlayerRank, int pageDirection) { ITask <RankingScores> task = rankingsClient.GetRankingTopScores(leaderboardId, timeDimension, maxResults, offsetPlayerRank, pageDirection); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] GetScoresFromLeaderboard SUCCESS"); OnGetScoresFromLeaderboardSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.Log("[HMS GAMES] GetScoresFromLeaderboard ERROR"); OnGetScoresFromLeaderboardFailure?.Invoke(exception); }); }
public void GetScoresFromLeaderboard(string leaderboardId, int timeDimension, int maxResults, int offsetPlayerRank, int pageDirection) { ITask <RankingScores> task = rankingsClient.GetRankingTopScores(leaderboardId, timeDimension, maxResults, offsetPlayerRank, pageDirection); task.AddOnSuccessListener((result) => { Debug.Log("[HMSLeaderboardManager] GetScoresFromLeaderboard SUCCESS"); OnGetScoresFromLeaderboardSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSLeaderboardManager]: GetScoresFromLeaderboard failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnGetScoresFromLeaderboardFailure?.Invoke(exception); }); }
//fetch() Fetches latest parameter values from Remote Configuration at the default //interval of 12 hours. If the method is called within an interval, cached data is returned. public void Fetch() { ITask <ConfigValues> x = agc.Fetch(); x.AddOnSuccessListener((configValues) => { Debug.Log("[HMSRemoteConfigManager] Fetch success."); OnFecthSuccess?.Invoke(configValues); }); x.AddOnFailureListener((exception) => { Debug.LogError("[HMSRemoteConfigManager]: Fetch failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnFecthFailure?.Invoke(exception); }); }
public void SilentSignIn() { ITask <AuthAccount> taskAuthHuaweiId = authService.SilentSignIn(); taskAuthHuaweiId.AddOnSuccessListener((result) => { HuaweiId = result; OnSignInSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { HuaweiId = null; Debug.LogError("[HMSAccountManager]: Silent Sign in failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnSignInFailed?.Invoke(exception); }); }
private void ConsumePurchase(string token) { ConsumeOwnedPurchaseReq consumeOwnedPurchaseReq = new ConsumeOwnedPurchaseReq(); consumeOwnedPurchaseReq.PurchaseToken = token; ITask <ConsumeOwnedPurchaseResult> task = iapClient.ConsumeOwnedPurchase(consumeOwnedPurchaseReq); task.AddOnSuccessListener((result) => { Debug.Log("HMSP: consumePurchase"); }).AddOnFailureListener((exception) => { Debug.Log("HMSP: Error on consumePurchase"); }); }
public void GetPlayerInfo() { if (HMSAccountManager.Instance.HuaweiId != null) { ITask <HuaweiMobileServices.Game.Player> task = playersClient.CurrentPlayer; task.AddOnSuccessListener((result) => { Debug.Log("[HMSGameManager] GetPlayerInfo Success"); OnGetPlayerInfoSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSGameManager]: GetPlayerInfo failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnGetPlayerInfoFailure?.Invoke(exception); }); } }
public void GetLeaderboardsData() { ITask <IList <Ranking> > task = rankingsClient.GetRankingSummary(true); task.AddOnSuccessListener((result) => { Debug.Log("[HMS GAMES] GetLeaderboardsData SUCCESS"); foreach (Ranking ranking in result) { Debug.Log("[HMS GAMES] Received " + ranking.RankingDisplayName + "data"); } }).AddOnFailureListener((exception) => { Debug.Log("[HMS GAMES] GetLeaderboardsData ERROR"); }); }
public void GetPlayerInfo() { if (accountManager.HuaweiId != null) { IPlayersClient playersClient = Games.GetPlayersClient(accountManager.HuaweiId); ITask <Player> task = playersClient.CurrentPlayer; task.AddOnSuccessListener((result) => { Debug.Log("[HMSP:] GetPlayerInfo Success"); OnGetPlayerInfoSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.Log("[HMSP:] GetPlayerInfo Failed"); OnGetPlayerInfoFailure?.Invoke(exception); }); } }
public void CheckIapAvailability() { iapClient = Iap.GetIapClient(); ITask <EnvReadyResult> task = iapClient.EnvReady; task.AddOnSuccessListener((result) => { Debug.Log("HMSP: checkIapAvailabity SUCCESS"); iapAvailable = true; OnCheckIapAvailabilitySuccess?.Invoke(); }).AddOnFailureListener((exception) => { Debug.Log("HMSP: Error on ObtainOwnedPurchases"); iapClient = null; iapAvailable = false; OnCheckIapAvailabilityFailure?.Invoke(exception); }); }
private void ObtainOwnedPurchases(OwnedPurchasesReq ownedPurchasesReq) { ITask <OwnedPurchasesResult> task = iapClient.ObtainOwnedPurchases(ownedPurchasesReq); task.AddOnSuccessListener((result) => { Debug.Log("[HMSIAPManager] ObtainOwnedPurchases"); foreach (var item in result.InAppPurchaseDataList) { Debug.Log("[HMSIAPManager] ProductId: " + item.ProductId + ", ProductName: " + item.ProductName + ", Price: " + item.Price); } OnObtainOwnedPurchasesSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSIAPManager]: ObtainOwnedPurchases failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnObtainOwnedPurchasesFailure?.Invoke(exception); }); }
public void Init() { Debug.Log("HMS GAMES init"); authService = HMSAccountManager.Instance.GetGameAuthService(); ITask <AuthAccount> taskAuthHuaweiId = authService.SilentSignIn(); taskAuthHuaweiId.AddOnSuccessListener((result) => { InitJosApps(result); SignInSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.Log("HMS GAMES: The app has not been authorized"); authService.StartSignIn((auth) => { InitJosApps(auth); SignInSuccess?.Invoke(auth); }, SignInFailure); InitGameManagers(); }); }
private void ObtainOwnedPurchaseRecord(OwnedPurchasesReq req) { ITask <OwnedPurchasesResult> task = iapClient.ObtainOwnedPurchaseRecord(req); task.AddOnSuccessListener((result) => { Debug.Log("HMSP: ObtainOwnedPurchaseRecord"); foreach (var item in result.InAppPurchaseDataList) { Debug.Log("[HMSPlugin]: ProductId: " + item.ProductId + ", ProductName: " + item.ProductName + ", Price: " + item.Price); } OnObtainOwnedPurchaseRecordSuccess?.Invoke(result); }).AddOnFailureListener((exception) => { Debug.Log("HMSP: Error on ObtainOwnedPurchaseRecord"); OnObtainOwnedPurchaseRecordFailure?.Invoke(exception); }); }