Android Question Admob Open bidding?

tufanv

Expert
Licensed User
Longtime User
Hello,

Finally I was approved for open bidding in admob. Does firebase admob library already supports this?
For pre-requisties it says:

  • Google Mobile Ads SDK 18.1.1 or higher.
Thanks
 

tufanv

Expert
Licensed User
Longtime User
Initialization is different then in normal AdMob, also manifest. AdMob lib for B4a and B4i have to be updated with new initialize method. Also additional SDK will be mandatory for some networks.

EDIT:
Manifest is easy but new initilaze method? How can we do that? any ideas?
 
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Load ad is also different, better to wait for Erel to change lib, it's <2 minutes job.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
@Erel can you help about this ? I Was mailing everyday admob about this and finally get it so I would be happy if I can use it. I see that loading ads may generate a problem only IF requests are not sent to other sources so it looks like this change is not mandatory. Inıtialize method also seems same but I am not sure as Pendrush says it is different.
 
Last edited:
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
You cannot load ads before fire of event OnInitializationCompleteListener. I don't know is current B4a lib have that event.
Also this:
The loadAds() method currently serves only Google ads. For mediated ads, use loadAd() instead.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can see the code here: https://github.com/AnywhereSoftware...esoftware/b4a/admobwrapper/AdViewWrapper.java
It doesn't call loadAds, though the library code isn't too important as the API is simple enough to call it with JavaObject.

Replace MobileAds.Initialize with:
B4X:
Sub MobileAdsInitialize As ResumableSub
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim jo As JavaObject
    jo.InitializeStatic("com.google.android.gms.ads.MobileAds")
    Dim CompleteListener As Object = jo.CreateEventFromUI("com.google.android.gms.ads.initialization.OnInitializationCompleteListener", "Complete", Null)
    jo.RunMethod("initialize", Array(ctxt, CompleteListener))
    Wait For Complete_Event (MethodName As String, Args() As Object)
    If MethodName = "onInitializationComplete" Then
        Dim jStatusMap As JavaObject = jo.RunMethodJO("getInitializationStatus", Null).RunMethod("getAdapterStatusMap", Null)
        Dim status As Map = JavaMapToB4AMap(jStatusMap)
        For Each AdapterName As String In status.Keys
            Dim st As JavaObject = status.Get(AdapterName)
            Log($"${AdapterName}: state: ${st.RunMethod("getInitializationState", Null)}"$)
        Next
    End If
    Return True
End Sub
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
You can see the code here: https://github.com/AnywhereSoftware...esoftware/b4a/admobwrapper/AdViewWrapper.java
It doesn't call loadAds, though the library code isn't too important as the API is simple enough to call it with JavaObject.

Replace MobileAds.Initialize with:
B4X:
Sub MobileAdsInitialize As ResumableSub
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim jo As JavaObject
    jo.InitializeStatic("com.google.android.gms.ads.MobileAds")
    Dim CompleteListener As Object = jo.CreateEventFromUI("com.google.android.gms.ads.initialization.OnInitializationCompleteListener", "Complete", Null)
    jo.RunMethod("initialize", Array(ctxt, CompleteListener))
    Wait For Complete_Event (MethodName As String, Args() As Object)
    If MethodName = "onInitializationComplete" Then
        Dim jStatusMap As JavaObject = jo.RunMethodJO("getInitializationStatus", Null).RunMethod("getAdapterStatusMap", Null)
        Dim status As Map = JavaMapToB4AMap(jStatusMap)
        For Each AdapterName As String In status.Keys
            Dim st As JavaObject = status.Get(AdapterName)
            Log($"${AdapterName}: state: ${st.RunMethod("getInitializationState", Null)}"$)
        Next
    End If
    Return True
End Sub
Can this method still be used with firebasse admob2? I need to see mediation adapter statuses .
 
Upvote 0
Top