Android Tutorial FirebaseAdMob - Rewarded video ads

Discussion in 'Tutorials & Examples' started by Erel, Sep 27, 2016.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Edit: Google AdMob does support rewarded ads without mediation.
    You can use this unit id to test it: rewardAd.LoadAd("ca-app-pub-3940256099942544/5224354917")
    Make sure to use FirebaseAdMob v1.51+

    FirebaseAdMob v1.30 adds support for rewarded video ads. Rewarded video ads are video ads where the user is rewarded if he watches the full video.
    How is the user rewarded is up to you. In many games for example, the users will receive an extra life if they watch the video ad.

    Google AdMob do not provide these ads. You need to use the mediation feature to add an ad network that does support rewarded videos. You can see the features that each ad network supports here: https://firebase.google.com/docs/admob/android/mediation-networks#supported-ad-formats
    I've tested it with InMobi.

    The first step is to integrate the third party ad network as explained here: AdMob Mediation (with InMobi)

    Working with RewardedVideoAd is similar to working with InterstitialAds. You first need to call LoadAd. Note that the ad unit is passed to the LoadAd method and not to the Initialize method.

    The ReceiveAd event will be raised when an ad is ready. Now you can call Ad.Show to show the ad. If the user will fully watch the ad then the Rewarded event will be raised.

    Example:
    Code:
    Sub Globals
       
    Private ad As RewardedVideoAd
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
       ad.Initialize(
    "ad")
    End Sub

    Sub Activity_Resume
       ad.LoadAd(
    "ca-app-pub-12345675929340/33333326118")
    End Sub

    Sub ad_ReceiveAd
       
    Log("Ad received. Now wait for the right moment to show the ad.")
    End Sub

    Sub Ad_Rewarded (Item As Object)
       
    'Item is currently not used
       ToastMessageShow("You are rewarded!!!"True)
    End Sub

    Sub Ad_FailedToReceiveAd (ErrorCode As String)
      
    Log("Failed: " & ErrorCode)
    End Sub

    Sub Ad_AdClosed
       
    Log("Closed")
    End Sub

    Sub Ad_AdOpened
       
    Log("Opened")
    End Sub

    Sub Activity_Click
       
    If ad.Ready Then ad.Show
    End Sub
     
    Last edited: May 31, 2018
    seanfogg, asales, Pendrush and 4 others like this.
  2. Davin

    Davin Member Licensed User

    erel, i dont know what i do wrong. but before.. i try the code, and i get the video ads running.

    but now.. i only get error code : 3.. which is ads not serving at all..

    even when i try to use test ads. it doesnt show a thing.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Check the unfiltered logs. There might be more information.
     
  4. Davin

    Davin Member Licensed User

    i got something like this
    Code:
    10-05 21:39:51.337 3255 3262 I art : Thread[2,tid=3262,WaitingInMainSignalCatcherLoop,Thread*=0x8ee0b000,peer=0x947e90a0,"Signal Catcher"]: reacting to signal 3
    10-05 21:39:51.448 3255 3262 I art : Wrote stack traces to '/data/anr/traces.txt'
    10-05 21:39:51.450 11598 11598 W Ads : Failed to load ad: 3
    10-05 21:39:51.452 11598 11598 I B4A : sending message to waiting queue (ad_failedtoreceivead)
    10-05 21:39:51.455 5527 5527 I B4A : sending message to waiting queue (ad_failedtoreceivead)
    10-05 21:39:51.573 3619 3624 I art : Thread[2,tid=3624,WaitingInMainSignalCatcherLoop,Thread*=0x8ee0b000,peer=0x948010a0,"Signal Catcher"]: reacting to signal 3
    10-05 21:39:51.746 3619 3624 I art : Wrote stack traces to '/data/anr/traces.txt'
    10-05 21:39:51.746 3632 3637 I art : Thread[2,tid=3637,WaitingInMainSignalCatcherLoop,Thread*=0x8ee0b000,peer=0x948010a0,"Signal Catcher"]: reacting to signal 3
    10-05 21:39:51.888 3643 3649 I art : Thread[2,tid=3649,WaitingInMainSignalCatcherLoop,Thread*=0x8ee0b000,peer=0x948020a0,"Signal Catcher"]: reacting to signal 3
    10-05 21:39:51.893 3632 3637 I art : Wrote stack traces to '/data/anr/traces.txt'
    10-05 21:39:52.046 3643 3649 I art : Wrote stack traces to '/data/anr/traces.txt'
    and actualy the ads is loaded

    Code:
    10-05 21:38:41.781 11305 11305 D InMobiAdapter: initialize called from InMobiAdapter.
    10-05 21:38:41.787 11305 11305 W Ads : Server parameters: {"gwhirl_share_location":"1","accountid":"xxxxx","placementid":"xxxx"}
    10-05 21:38:41.788 11305 11305 D InMobiAdapter: Bundle extras are null
    but no sign of the ads
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Not sure. Does it happen if you create a new project with only the ads related code?
     
  6. Davin

    Davin Member Licensed User

    yes. i make a new project. and basically copy and paste your code with my admob id.

    still get error failed:3
     
  7. sorex

    sorex Expert Licensed User

    3 means there are currently no ads for you
     
  8. capisx

    capisx Member Licensed User

    I got this problem too, i've test this rewarded video ads more than a week and it's still show error code: 3. Tested with the latest firebase admob lib v1.31 with the same result. I've checked the mediation report and the ads request was reported in that report but with 0,00% fillrate, it looks like the request was not submitted to inmobi server.
     
  9. Davin

    Davin Member Licensed User

    +1 here.. soo.. is there any possibilities that someone can release the other library .. for unity ads maybe ?
     
  10. Erel

    Erel Administrator Staff Member Licensed User

  11. capisx

    capisx Member Licensed User

  12. Davin

    Davin Member Licensed User

    this work well with me too. but .. damn me. i try with 6.0.1 and now ads not displayed. can u upload your libadapterinmobi file that work with 5.3.1 ?
     
  13. capisx

    capisx Member Licensed User

  14. seanfogg

    seanfogg Member Licensed User

    Hi, I have an issue which is driving me mad, as soon as I invoke the Show Method the video plays but the background process restarts the main activity_create which causes all sorts of problems. With interstitial ads the main activity process is paused until the ad is closed and then continues as normal, is there anyway I can replicate this action while the video is playing then resume after it is closed?
     
  15. seanfogg

    seanfogg Member Licensed User

    I've answered my own question, had to add a new activicty and pass all the video ad processing to that, still had a lot of problems returning back to the main activity but managed to figure it out :)
     
  16. seanfogg

    seanfogg Member Licensed User

    Hi, got another question, is there any way of trapping whether a user has clicked through during or at the end of a video? I know that the rewarded event fires if the video finishes but can you tell if they clicked the ad itself? I am thinking of offering a higher reward other than just watching it.
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    The AdLeftApplication event should be raised when the user clicks on the ad.
     
  18. sorex

    sorex Expert Licensed User

    I'm having a look at this and all I seem to get is static interstitials?

    Do I need a specific minimum api (I changed it from 9 to 14 for min & target) or something else ?

    I used the chartboost adapter, not the inmobi one tho.

    The rewarded video counter in admob increases so it's the right ID etc.
     
  19. sorex

    sorex Expert Licensed User

    it's ok. setting the floor of admob to 0.01 solved it.
     
  20. alimanam3386

    alimanam3386 Active Member Licensed User

    Hi,

    How can we use this ad for test ( in physical device ) ? In AdView we have LoadAdWithTestDevice method but for RewardedVideoAd we dont have. how can we use it befor realse our application ?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice