MAS Knowledge Base

MAS Knowledge Base

Docy

Rewarded Ads

1. Configure the ad events

				
					Yodo1MasRewardAd.getInstance().setAdListener(new Yodo1MasRewardAdListener() {

	@Override
	public void onRewardAdLoaded(Yodo1MasRewardAd ad) {

	}

	@Override
	public void onRewardAdFailedToLoad(Yodo1MasRewardAd ad, @NonNull Yodo1MasError error) {

	}

	@Override
	public void onRewardAdOpened(Yodo1MasRewardAd ad) {

	}

	@Override
	public void onRewardAdFailedToOpen(Yodo1MasRewardAd ad, @NonNull Yodo1MasError error) {
       ad.loadAd(MainActivity.this);
	}

	@Override
	public void onRewardAdClosed(Yodo1MasRewardAd ad) {
        ad.loadAd(MainActivity.this);
	}

        @Override
        public void onRewardAdEarned(Yodo1MasRewardAd ad) {
        
        }
});
				
			
				
					Yodo1MasRewardAd.getInstance().setAdListener(object : Yodo1MasRewardAdListener {
    
    override fun onRewardAdLoaded(ad: Yodo1MasRewardAd?) {

    }

    override fun onRewardAdFailedToLoad(ad: Yodo1RewardAd?, error: Yodo1MasError) {

    }

    override fun onRewardAdOpened(ad: Yodo1MasRewardAd?) {

    }

    override fun onRewardAdFailedToOpen(ad: Yodo1MasRewardAd?,error: Yodo1MasError) {
        ad.loadAd(this@MainActivity)
    }

    override fun onRewardAdClosed(ad: Yodo1MasRewardAd?) {
        ad.loadAd(this@MainActivity)
    }

    override fun onRewardAdEarned(ad: Yodo1MasRewardAd?) {
       
    }
})
				
			

2. Load the ad

				
					Yodo1MasRewardAd.getInstance().loadAd(MainActivity.this);
				
			
				
					Yodo1MasRewardAd.getInstance().loadAd(this@MainActivity)
				
			

3. Show the ad

				
					boolean isLoaded = Yodo1MasRewardAd.getInstance().isLoaded();
if(isLoaded) Yodo1MasRewardAd.getInstance().showAd(MainActivity.this, "Your Placement");
				
			
				
					val isLoaded = Yodo1MasRewardAd.getInstance().isLoaded()
if(isLoaded) Yodo1MasRewardAd.getInstance().showAd(this@MainActivity, "Your Placement")
				
			

The ad placement parameter is optional. You can use it to analyze the performance of your ads or run an A/B test to help you optimize your monetization strategy.

You can learn more about the ad placements here.

4. Video tutorial

CONTENTS