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:

Jack Cole

Well-Known Member
Licensed User
Longtime User
On a PC with Windows 8, I'm using the hosted builder. I did update the iAdmob library to the latest version, but that didn't help. Any ideas?

B4X:
Ld Payload/Minesweeper.app/Minesweeper normal armv7
    cd /Users/administrator/Documents/UploadedProjects/art2huz
    export IPHONEOS_DEPLOYMENT_TARGET=7.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk -L/Users/administrator/Documents/UploadedProjects/art2huz/Payload -L../../Libs -F/Users/administrator/Documents/UploadedProjects/art2huz/Payload -F../../Libs -filelist /Users/administrator/Documents/UploadedProjects/art2huz/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/Minesweeper.LinkFileList -ObjC -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=7.0 -lCore -framework Foundation -framework CoreGraphics -framework UIKit -liHttp -liSQL -liAdMob -liJSON -framework AVFoundation -lsqlite3 -framework AudioToolbox -framework AdSupport -framework CoreGraphics -framework CoreTelephony -framework EventKit -framework EventKitUI -framework MessageUI -framework StoreKit -framework SystemConfiguration -lGoogleAdMobAds -framework GoogleMobileAds -liDebug -Xlinker -dependency_info -Xlinker /Users/administrator/Documents/UploadedProjects/art2huz/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/Minesweeper_dependency_info.dat -o /Users/administrator/Documents/UploadedProjects/art2huz/Payload/Minesweeper.app/Minesweeper
ld: library not found for -lGoogleAdMobAds
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Error: ** BUILD FAILED **


The following build commands failed:
    Ld Payload/Minesweeper.app/Minesweeper normal armv7
(1 failure)
 

susu

Well-Known Member
Licensed User
Longtime User
I'm using iAdMob v1.2 and hosted builder. I got this error when try to load ad:

<Google:HTML> You are currently using version 7.0.0 of the SDK. Please consider updating your SDK to the most recent sdk version to get the latest features and bug fixes. The latest SDK can be downloaded from http://goo.gl/iGzfsP. A full list of release notes is available at https://developers.google.com/mobile-ads-sdk/docs/admob/ios/rel-notes

Do I need to wait for @Erel to update the SDK?
 

susu

Well-Known Member
Licensed User
Longtime User
@Erel I'm waiting for updated lib to publish my app. Thank you.
 

salvadoro

Member
Licensed User
Longtime User
Hi i'm already copy libGoogleAdMobAds.a to the libs directory, but i get this error:

ld: framework not found GoogleMobileAds

i'm using B4i v2 and macserverv2

Regards,

Salvador.
 

ilan

Expert
Licensed User
Longtime User
B4X:
Sub Process_Globals
   Dim adview1 As AdView
End Sub

'...

Private Sub Application_Start (Nav As NavigationController)
'...
    adview1.Initialize("Ad","ca-app-pub-xxxxx",Page1, adview1.SIZE_SMART_BANNER_PORTRAIT)
    adview1.LoadAd 
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
        Dim height As Int = 50
        Page1.RootPanel.AddView(adview1, 0,Page1.RootPanel.height-height, Page1.RootPanel.Width, height)
        adview1.BringToFront
End Sub
'...
 
Last edited by a moderator:

abhishek007p

Active Member
Licensed User
Longtime User
ReceiveAd event was fired but no Ad was displayed. i found the problem and fixed it, ads was appearing but outside the screen area. so we have resize the adview in the page resize event.

there is a difference of 64px in the height of page if we get the value outside of page resize event. (strange)

B4X:
Private Sub Page1_Resize(Width As Int, Height As Int)
    If AdView1.IsInitialized = True Then
        AdView1.SetLayoutAnimated(0, 1, 0, 100%y - GetAdHeight, 100%x, GetAdHeight)
    End If
End Sub

Here is how to get the device ID:
First run the code using any dummy text as publisher id, it will produce an error but shows the device id in log like this.
<Google> To get test ads on this device, call: request.testDevices = @[ @"<DeviceID>" ];

Copy the Device ID and get sample publisher ID from links below.
https://developers.google.com/admob/ios/quick-start
 
Last edited:

abhishek007p

Active Member
Licensed User
Longtime User
Image 1 - Test Banner Ads 50px height
1.png

Image 2 - Test Banner 200px height ad (non standard height)
2.png

Image 3 - ilan's pub id, banner ad 32px height
3.png

Image 4 - Test Interstitial Ads
4.png

All Test Done using B4I 1.80 and AdMob 1.21
 
Last edited:

ilan

Expert
Licensed User
Longtime User
yes you are right, i copy/past the part from page resize sub to app start sub... sorry :)
 
Status
Not open for further replies.
Top