Admob Rewarded Video support for Xamarin

Hi!

I've been struggling for some time to implement rewarded video ads in my app, using Admob network. I've managed to display a video ad on android, but I simply can't have the listener to trigger the OnRewarded event. This is how I implement it:

`

public class AdMobInter : IAdmobInter
{
    InterstitialAd _ad;

    public void Show(string adUnit)
    {
        var context = Android.App.Application.Context;
        _ad = new InterstitialAd(context);
        _ad.AdUnitId = adUnit;

        var intlistener = new InterstitialAdListener(_ad);
        intlistener.OnAdLoaded();
        _ad.AdListener = intlistener;

        var requestbuilder = new AdRequest.Builder();

        _ad.LoadAd(requestbuilder.Build());
    }
}

public class InterstitialAdListener : AdListener, IRewardedVideoAdListener
{
    readonly InterstitialAd _ad;

    public InterstitialAdListener(InterstitialAd ad)
    {
        _ad = ad;
        _ad.RewardedVideoAdLoaded += (o, e) => OnRewardedVideoAdLoaded();
        _ad.RewardedVideoAdClosed += (o, e) => OnRewardedVideoAdClosed();
    }

    public override void OnAdLoaded()
    {
        base.OnAdLoaded();

        if (_ad.IsLoaded)
        {
            _ad.Show();
    //THIS EVENT WORKS//
            //MY CODE HERE//

        }
    }

    public override void OnAdFailedToLoad(int errorCode)
    {
        base.OnAdFailedToLoad(errorCode);
//THIS EVENT WORKS//
        //MY CODE HERE//
    }

    public void OnRewarded(IRewardItem reward)
    {
     //THIS EVENT WON'T TRIGGER//
    //MY CODE HERE//
    }

    public void OnRewardedVideoAdClosed()
    {
        //THIS EVENT WORKS//
    //MY CODE HERE//
    }

    public void OnRewardedVideoAdFailedToLoad(int errorCode)
    {

    }

    public void OnRewardedVideoAdLeftApplication()
    {

    }

    public void OnRewardedVideoAdLoaded()
    {
        //THIS EVENT WORKS//
    //MY CODE HERE//
    }

    public void OnRewardedVideoAdOpened()
    {

    }

    public void OnRewardedVideoStarted()
    {

    }
}

`

I've read in some places that the Admob network only support native frameworks, and Xamarin is still not supported. Is this really the case? I'm thinking in just leaving it like that and the user will get an internal reward regardless of watching the whole video or not. It's not ideal for me, but what can I do? I'm using a PCL project, currently working on the Android.

How do you guys deal with that in your apps? Any hint is appreciated!

Posts

  • 15mgm1515mgm15 USMember ✭✭✭✭

    This is for Xamarin Android:

    https://stackoverflow.com/questions/42000060/xamarin-android-reward-video

    But you can use the DependencyService to try it.

  • RaelsonCraftzRaelsonCraftz BRMember ✭✭

    Yeah, I do it in a similar way using DependencyServices. Everything works, except for the OnRewarded event that simply won't trigger. It's as if the Listener just won't notice the reward, although the loading and closing events work properly for the video.

  • batmacibatmaci DEMember ✭✭✭✭✭
    Did you find finally some good solution here? İ am looking for it also. Please let me know. Thanks
  • RaelsonCraftzRaelsonCraftz BRMember ✭✭

    I've kept only using the rewarded video without the Listener detecting the OnRewarded event. My idea at the time I posted this is that the feature itself still needs to be implemented by Xamarin or Firebase. If I'm wrong there, please someone correct me. Some light on this matter would be really helpful.

    The OnRewardedVideoAdClosed() works fine, but I still can't trigger the OnRewarded(IRewardItem reward)

  • batmacibatmaci DEMember ✭✭✭✭✭

    @RaelsonCraftz could it be because you are using InterstitalAd instead of RewardedAd. if you see the android documentation ,
    com.google.android.gms.ads.reward.RewardedVideoAd has but when I check Android.Gms.Ads.Reward namespace it doesnt have RewardedVideoAd object. it looks like Xamarin library doesnt implement it.

  • batmacibatmaci DEMember ✭✭✭✭✭

    I was correct with my assumption. see this entry here. i have implemented as in his code and it all works fine for me. OnRewarded is getting called. https://forums.xamarin.com/discussion/66452/xamarin-admob-rewardedvideoad

  • RaelsonCraftzRaelsonCraftz BRMember ✭✭

    @batmaci That's really neat! I'll try to implement that on my apps when I've some spare time and will post here. Thanks!

  • batmacibatmaci DEMember ✭✭✭✭✭

    @RaelsonCraftz said:
    @batmaci That's really neat! I'll try to implement that on my apps when I've some spare time and will post here. Thanks!

    hey, i dont know if i am using something wrong but i use mixed rewarded and interstitial ads and rewarded ads brings less revenue. totally disappointing with admobs

  • MarcoTronconeMarcoTroncone GBUniversity ✭✭✭

    Hi,
    my free plugin https://www.nuget.org/packages/MarcTron.Admob supports Banner, Interstitial and Rewarded Video for Android and iOS and it's incredibly easy to use, so you can try it in case you still need it.

    On my blog you can also find a tutorial: https://www.xamarinexpert.it/blog/admob-made-easy

    If you need help, let me know.

Sign In or Register to comment.