B4i Library Firebase v3.00 + iAdMob v4.10 + Facebook 9.3

Edit: Latest version of Firebase + iAdMob is included with the builder.

A new package with an updated Firebase and AdMob sdks is available.


Updates:

- iAdMob v4.10 is included in the package. It fixes an issue with RewardsAds not raising events. Note that the internals of this type have changed. You can use NativeObject.GetField("ad") to get the native ad.
- iAdMob v4.0 is included in the package.
This includes implementation of UMP: https://developers.google.com/admob/ios/privacy
Note that you must add your AdMob app id:
Code: Copy
'Main module
#PlistExtra:<key>GADApplicationIdentifier</key>
'this is a test app id.
#PlistExtra:<string>ca-app-pub-3940256099942544~1458002511</string>

Example:
Code: Copy
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ump As UMPConsentInformation
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    ump.Initialize("ump")
    ump.Reset
'    ump.UpdateAndRequestIfNeededDebug(B4XPages.GetNativeParent(Me), Array("1A3BEBAD-587A-4600-9845-89C79B863C7D"), True)
    ump.UpdateAndRequestIfNeeded(B4XPages.GetNativeParent(Me))
    Wait For ump_Update (Success As Boolean)
    Log("success: " & Success)
    Log("canRequestAds: " & ump.CanRequestAds)
    If ump.CanRequestAds Then
        Dim ad As AdView
        ad.Initialize("ad", "ca-app-pub-3940256099942544/2934735716", B4XPages.GetNativeParent(Me), ad.SIZE_BANNER)
        If Root.Width = 0 Or Root.Height = 0 Then
            Wait For B4XPage_Resize (Width As Int, Height As Int)
        End If
        Root.AddView(ad, 0, 0, Root.Width, 50dip)
        ad.LoadAd
    End If
End Sub

Sub ad_FailedToReceiveAd (ErrorCode As String)
    Log("fail: " & ErrorCode)
End Sub

Sub ad_ReceiveAd
    Log("receive")
End Sub
 
Last edited:
- iAdMob v4.10 is included in the package. It fixes an issue with RewardsAds not raising events. Note that the internals of this type have changed. You can use NativeObject.GetField("ad") to get the native ad.

The library is attached. The zip includes the Mac files (.a / .h) and the internal library file (.xml).

Usage example:
Code: Copy
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    rew.Initialize("rew")
    LoadAd
End Sub

Private Sub LoadAd
    btnShowRewardAd.Enabled = False
    rew.LoadAd("ca-app-pub-3940256099942544/1712485313")
End Sub

Private Sub rew_ReceiveAd
    Log("receive ad")
    btnShowRewardAd.Enabled = True
End Sub

Private Sub rew_FailedToReceiveAd (ErrorCode As String)
    Log("failed: " & ErrorCode)
    btnShowRewardAd.Enabled = False
End Sub

Private Sub rew_Rewarded (Item As Object)
    Log("rewarded: " & Item)
End Sub

Private Sub rew_AdOpened
    Log("ad opened")
End Sub

Private Sub rew_AdClosed
    Log("ad closed")
    LoadAd    
End Sub

Private Sub btnShowRewardAd_Click
    If rew.Ready Then
        rew.Show(B4XPages.GetNativeParent(Me))
    End If
End Sub

And in main module:
Code: Copy
#PlistExtra:<key>GADApplicationIdentifier</key>
'this is a test app id.
#PlistExtra:<string>ca-app-pub-3940256099942544~1458002511</string>

And make sure to use provision profile with in app purchases capability.
 

Attachments

Similar Threads

Replies
3
Views
3K
  • Locked
  • Article Article
Replies
4
Views
7K
  • Locked
  • Article Article
B4i Library iAdMob
Replies
108
Views
65K
Back
Top