iOS Tutorial AdMob - Rewarded video ads

Discussion in 'iOS Tutorials' started by Erel, Oct 9, 2016.

  1. Erel

    Erel Administrator Staff Member Licensed User

    AdMob v1.50 (included in B4i v3.0) 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.

    AdMob doesn't serve such ads directly. You need to use the mediation feature to add an ad network that does support such ads.

    Start with this tutorial: https://www.b4x.com/android/forum/threads/admob-ads-mediation-with-inmobi.71837/

    You need to create a Rewarded interstitial ad in AdMob and add the third party network as a source.

    SS-2016-10-09_16.48.14.png

    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.

    Code:
    #AdditionalLib: InMobiSDK.framework.3
    #AdditionalLib: AdapterInMobi
    #AdditionalLib: libsqlite3.dylib
    #AdditionalLib: libz.dylib
    #AdditionalLib: WebKit.framework
    Sub Process_Globals
       
    Public App As Application
       
    Public NavControl As NavigationController
       
    Private Page1 As Page
       
    Private rew As RewardedVideoAd
    End Sub


    Private Sub Application_Start (Nav As NavigationController)
       NavControl = Nav
       Page1.Initialize(
    "Page1")
       Page1.Title = 
    "Page 1"
       Page1.RootPanel.Color = 
    Colors.White
       NavControl.ShowPage(Page1)
       rew.Initialize(
    "rew")
       rew.LoadAd(
    "ca-app-pub-12675722222222/852222222")
    End Sub

    Sub Page1_Click
       
    If rew.Ready Then rew.Show(Page1)
    End Sub

    Sub rew_AdOpened
       
    Log("ad opened")
    End Sub

    Sub rew_FailedToReceiveAd (ErrorCode As String)
       
    Log("Failed to receive ad: " & ErrorCode)
    End Sub

    Sub rew_ReceiveAd
       
    Log("receive ad")
    End Sub

    Sub rew_Rewarded (Item As Object)
       
    Log("Rewarded: " & Item)
    End Sub
     
    jazzzzzzz and Pendrush like this.
Loading...