A
A
Alexander2020-10-16 18:09:34
Unity
Alexander, 2020-10-16 18:09:34

Explain how rewarded advertising logic works (with ready-made code)?

Again, I use Easy Mobile Pro and they write the following in their documentation:

Working with Rewarded Ads
The method to show a rewarded ad requires it to be already loaded. Therefore you should check for the ad's availability before showing it.

// Check if rewarded ad is ready
bool isReady = Advertising.IsRewardedAdReady();

// Show it if it's ready
if (isReady)
{
    Advertising.ShowRewardedAd();
}

With this it is clear, when the advertisement is ready - we show it.

A RewardedAdCompleted event will be fired whenever a rewarded ad has completed. You should listen to this event to reward the user for watching the ad. Otherwise, a RewardedAdSkipped event will be fired if the ad is skipped before finishing (and the user therefore is not entitled to the reward).

// Subscribe to rewarded ad events
void OnEnable()
{
    Advertising.RewardedAdCompleted += RewardedAdCompletedHandler;
    Advertising.RewardedAdSkipped += RewardedAdSkippedHandler;
}

// Unsubscribe events
void OnDisable()
{
    Advertising.RewardedAdCompleted -= RewardedAdCompletedHandler;
    Advertising.RewardedAdSkipped -= RewardedAdSkippedHandler;
}

// Event handler called when a rewarded ad has completed
void RewardedAdCompletedHandler(RewardedAdNetwork network, AdLocation location)
{
    Debug.Log("Rewarded ad has completed. The user should be rewarded now.");
}

// Event handler called when a rewarded ad has been skipped
void RewardedAdSkippedHandler(RewardedAdNetwork network, AdLocation location)
{
    Debug.Log("Rewarded ad was skipped. The user should NOT be rewarded.");
}

And where to add it and how it should work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2020-10-16
@AlexandrG44

Add to monobeh. What is unclear at work? Usual events, everyone signed up. Somewhere inside the library, the event will be called - and pull your signature

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question