Exemple #1
0
    public void RewardAdActivity()
    {
        // RewardAdActivity
        // https://docs.microsoft.com/en-us/rest/api/playfab/client/advertising/rewardadactivity

        PlayFabClientAPI.RewardAdActivity(new RewardAdActivityRequest {
            PlacementId = PlacementId, RewardId = RewardId
        }
                                          , result =>
        {
            Debug.Log("GrantedVirtualCurrencies:" + result.RewardResults.GrantedVirtualCurrencies["GD"]);
            OnRewardFinished?.Invoke();
        }, error =>
        {
            if (error.Error == PlayFabErrorCode.AllAdPlacementViewsAlreadyConsumed)
            {
                Debug.Log("Run GetAdPlacements again.");
            }

            Debug.Log(error.GenerateErrorReport());
        });
    }
Exemple #2
0
    /// <summary>
    /// 報酬の付与
    /// </summary>
    public async void RewardAdActivityAsync()
    {
        var request = new RewardAdActivityRequest
        {
            PlacementId = PlacementId,
            RewardId    = RewardId
        };
        var result = await PlayFabClientAPI.RewardAdActivityAsync(request);

        if (result.Error != null)
        {
            if (result.Error.Error == PlayFabErrorCode.AllAdPlacementViewsAlreadyConsumed)
            {
                Debug.Log("You have exceeded the viewing limit for video ads.");
            }
            Debug.Log(result.Error.GenerateErrorReport());
        }
        else
        {
            Debug.Log("GrantedVirtualCurrencies:" + result.Result.RewardResults.GrantedVirtualCurrencies["MS"]);
            OnRewardFinished?.Invoke();
        }
    }