B4i Library iAdMob

Status
Not open for further replies.
Latest version: https://www.b4x.com/android/forum/threads/firebase-admob-v3-00.144798/#content

iAdMob v1.10 adds support for interstitial ads (full screen ads).

In order to show an interstitial ad you need to first request an ad and wait for the Ready event.
If Success is true then there is an ad ready to be displayed. You can then call iad.Show(Page) to show it.
You can also call iad.RequestAd again to request a new ad.

Note that you can show test ads by calling:
B4X:
iad.SetTestDevices(Array("121212121212")) 'id that is displayed in the logs
The ready event:
B4X:
Sub iad_Ready (Success As Boolean)
   If Success Then
     Log("iad is ready.")
     iad.Show(Page1)
   Else
     Log("Failed to load full screen ad: " & LastException)
   End If
End Sub

Note that you can show the ad after this event. This event only means that there is an ad ready to be displayed.

Library installation

iAdMob is an internal library now. It is preinstalled with the IDE.

If you are using a local Mac builder you need to download the new SDK and copy GoogleMobileAds.framework to the Libs folder: www.b4x.com/b4i/files/libGoogleAdMobAds.a.zip

Update:

Starting from Google Maps Ads SDK v7.42.0 it is required to add these lines:
B4X:
#PlistExtra: <key>GADIsAdManagerApp</key><true/>
#AdditionalLib: libsqlite3.dylib
#AdditionalLib: libz.dylib
#AdditionalLib: WebKit.framework
 
Last edited:

tucano2000

Active Member
Licensed User
Longtime User
I've just tested it with the latest version of AdMob SDK and it compiles and runs successfully.

How did you download the SDK? Make sure to download it directly from the Mac. It can be corrupted if you download it from a PC.

Ok Erel, reading your post I decided to check the possibility of the file being corrupted. I downloaded again now for the Mac because before had done the PC and transferred over the network.

It was exactly what you said happened. I do not understand the file's subject is corrrompido, but the fact is that now is working.

Great Erel you are the Pope programming :)
 

frenkipi

Member
Licensed User
Longtime User
Hello, sometimes the interstitial ad is openning again just after I close that ad. So let's say if a fullscreen ad opens, and I close it as soon as it opens, it opens again, but if I leave it open for about 5-10 seconds it doesn't open again. Is this behaviour normal? Or is it something with my code? And one thing, it is maybe that I allways call
B4X:
iad.RequestAd

on page_Appear?

Regards!
 

frenkipi

Member
Licensed User
Longtime User
Hello, yes I am using an
B4X:
iad.RequestAd
on my page_appear sub and on iad_Ready sub I am showing an ad.
B4X:
Sub iad_Ready (Success As Boolean)
    If Success Then
        Log("iad is ready.")
            iad.Show(myPage)           
    Else
        Log("Failed to load full screen ad: " & LastException)
    End If
End Sub

Any idea how can I limit this behaviour?

Thank you.
 

Yvon Steinthal

Active Member
Licensed User
Longtime User
try this out

Hello, i think im missing something, Your "ca-app..." works on my app, but doesnt with mine...

"Failed to load full screen ad: <B4IExceptionWrapper: Error Domain=com.google.ads Code=1 "Request Error: No ad to show." UserInfo={NSLocalizedDescription=Request Error: No ad to show., NSLocalizedFailureReason=Request Error: No ad to show.}>"


EDIT: I think its because i didnt add payment information. I have to wait to see if that changes anything...
 
Last edited:

ilan

Expert
Licensed User
Longtime User
Hello, i think im missing something, Your "ca-app..." works on my app, but doesnt with mine...

"Failed to load full screen ad: <B4IExceptionWrapper: Error Domain=com.google.ads Code=1 "Request Error: No ad to show." UserInfo={NSLocalizedDescription=Request Error: No ad to show., NSLocalizedFailureReason=Request Error: No ad to show.}>"


EDIT: I think its because i didnt add payment information. I have to wait to see if that changes anything...

you should use the .isReady method to check if an ad was successfully loaded and then show the ad.
if there are no ads comming you should check with admob why you dont get any ads.
make sure also to use the latest iadmob lib and admob sdk.
 
Status
Not open for further replies.
Top