/// <summary> /// Primary method used to send a Reward request to the RewardMob API /// </summary> /// <param name="message">A short description of the Reward was earned</param> /// <param name="amount">The amount of Rewards the user should receive (typically 1-3)</param> public void SendReward(string message, int amount) { //if the user is from a country where RewardMob is supported if (this.userInSupportedCountry) { //increment logical count of rewards _RewardCount += amount; //send off the reward request RewardMobRequestGateway.instance.SendReward(amount, message, //If successful, this callback will be fired successReward => { //increment physical count _TotalRewardCount += amount; sessionEarnedReward = true; //play reward dropdown message if (RewardMobAnimationManager.instance != null) { RewardMobAnimationManager.instance.PlayDropdownAnimation( RewardMobAnimationManager.RewardMobDropdownType.REWARD, successReward.comment, rewardCount: successReward.totalRewards ); } //update reward count UI rewardMobButton.GetComponent <RewardMobButton>().UpdateCount(_RewardCount); }, //if failed, this callback will be fired failedMessage => { _RewardCount -= amount; //play error dropdown animation if (RewardMobAnimationManager.instance != null) { RewardMobAnimationManager.instance.PlayDropdownAnimation( RewardMobAnimationManager.RewardMobDropdownType.WARNING, failedMessage ); } } ); //check to see if it was the first reward earned to pop open webview if (earnedState != RewardMobAuthorizedState.EARNED_FIRST_REWARD) { earnedState = RewardMobAuthorizedState.NOT_EARNED_FIRST_REWARD; } } }
/// <summary> /// Pop open a WebView for when an unauthorized user earns a Reward for the first time (Onboarding) /// </summary> private void ShowFirstTimeEarnedRewardScreen() { #if !UNITY_EDITOR if ((earnedState == RewardMobAuthorizedState.NOT_EARNED_FIRST_REWARD) && (Token == null)) { ToggleLoadingScreen(true); SampleWebView.Init(); try { SampleWebView.webViewObject.LoadURL(RewardMobEndpoints.GetWebViewURL(useLogicalRewards: true)); earnedState = RewardMobAuthorizedState.EARNED_FIRST_REWARD; } catch { Debug.LogError("Fill out the Game ID section inside of the RewardMobData object at RewardMobSDK/Resources."); } } #endif }