Hello
I'd like to share a class that I made for Reward Ads that I use in my apps/games.
It's little bit different from what is found here: https://www.b4x.com/android/forum/t...2-google-mobile-ads-v20-0.129696/#post-815445
Before starts, another excellent option is found here: https://www.b4x.com/android/forum/t...b2-google-mobile-ads-v20-0.129696/post-828193
This class works both on B4XPages or non-B4XPages.
Depends on:
How it works:
Starter service:
Activity or class (b4xpages):
RewardAd.Initialize(Callback As Object, EventName As String, Intersticial As Boolean, AdUnit As String, AutoLoad As Boolean, NonPersonalizedAds As Boolean)
Intersticial = True -> Rewarded Intersticial Ad -> https://developers.google.com/admob/android/rewarded-interstitial
Intersticial = False -> Rewarded Ad -> https://developers.google.com/admob/android/rewarded-fullscreen
AutoLoad -> load new ad every time
NonPersonalizedAds -> True (family program)
When you want to use:
Callbacks:
I'd like to share a class that I made for Reward Ads that I use in my apps/games.
It's little bit different from what is found here: https://www.b4x.com/android/forum/t...2-google-mobile-ads-v20-0.129696/#post-815445
Before starts, another excellent option is found here: https://www.b4x.com/android/forum/t...b2-google-mobile-ads-v20-0.129696/post-828193
This class works both on B4XPages or non-B4XPages.
Depends on:
FirebaseAdMob2 - Google Mobile Ads SDK v20+
This is a wrapper for Google Mobile Ads v20+ SDK. It is a modified version of FirebaseAdmob (1). This library works with Google Mobile Ads v20+. The previous library works with v19-. Note that you can use FirebaseAdMob2 without creating a Firebase account. It supports banner ads and...
www.b4x.com
How it works:
Starter service:
B4X:
Sub Service_Start (StartingIntent As Intent)
RewardAd.Initialize(Me, "RewardAd", False, "ca-app-pub-xxxxxxx/xxxxxx", True, True)
Dim m As MobileAds
Wait For (m.Initialize) MobileAds_Ready
RewardAd.LoadAd
End Sub
Activity or class (b4xpages):
B4X:
Sub Activity_Resume (or B4XPage_Appear)
Starter.RewardAd.Callback = Me
End Sub
RewardAd.Initialize(Callback As Object, EventName As String, Intersticial As Boolean, AdUnit As String, AutoLoad As Boolean, NonPersonalizedAds As Boolean)
Intersticial = True -> Rewarded Intersticial Ad -> https://developers.google.com/admob/android/rewarded-interstitial
Intersticial = False -> Rewarded Ad -> https://developers.google.com/admob/android/rewarded-fullscreen
AutoLoad -> load new ad every time
NonPersonalizedAds -> True (family program)
When you want to use:
B4X:
If Starter.RewardAd.Ready Then
Starter.RewardAd.Show
End If
Callbacks:
B4X:
Sub RewardAd_Rewarded (Item As Object)
...
End Sub
B4X:
Sub RewardAd_AdClosed
'If you set AutoLoad true, you don't need load another ad here.
End Sub