callback for reward yes/no

Possible to make RewardUserRewarded fire even when user is not rewarded??

I need to handle different code depending on if user was rewarded or not… and it can’t be done “safely” right now with these 2 callbacks…
RewardAdClosed - don’t know if the user was rewarded or not
RewardUserRewarded - not fired when user is not rewarded

1 Like

hi @mrm83_1
This is an interesting issue, but one we can’t really control. The Rewarded callback is provided by the ad networks. We can’t guarantee for example that Close will be called after OnRewarded.
We have some use cases that require that distinction on our end, and what we did is wait a bit after a Close callback to ensure we got the Rewarded callback if there was one.
You could locally implement something similar. if you get the rewarded callback, you know it was rewarded. if you get Close, start a timer and if by the end you didn’t get a rewarded, you can tell it was not. The timer duration is not something we can guarantee, but 1 second should be more than enough (still no guarantees, I recommend you run your own tests)

Hope that helps! :slight_smile:

Sometimes 1 second isn’t enough, so I set it to wait up to 3 seconds.
At 1 second, many users can’t get reward, so I added 2 seconds.

Declare a bool variable and change it to true in UserRewarded.
And in AdClosed, I checked that the variable was true and give the reward.

   void UserRewarded(object sender, RewardEventArgs args)
    {
        // Process for rewarding users
        _userGetReward = true;
    }

    void AdClosed(object sender, EventArgs e)
    {
        StartCoroutine(WaitForRewardCallback());
    }

    IEnumerator WaitForRewardCallback()
    {
        yield return new WaitForSeconds(1f);
        if (_userGetReward)
        {
            // user get reward
            yield break;
        }
        yield return new WaitForSeconds(2f);
        if (_userGetReward)
        {
            // user get reward
            yield break;
        }
        // Process for ad skip users
    }
1 Like

Yes, waiting may work, however, this hack fix is not safe implementation.