B4i Library iAdMob

Status
Not open for further replies.
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:

sorex

Expert
Licensed User
@Erel ,

Can we stop the refresh of a banner view?

I don't see .pause or .resume like in the android lib.
 

Pendrush

Well-Known Member
Licensed User
I'm unable to compile app with latest version of AdMob SDK (v7.9.1), using iAdMob lib v1.32
https://firebase.google.com/docs/admob/ios/download
Undefined symbols for architecture armv7:
"_GLKMatrix4Identity", referenced from:
l2392 in GoogleMobileAds(flat-armv7)
l2402 in GoogleMobileAds(flat-armv7)
"_OBJC_CLASS_$_CMMotionManager", referenced from:
objc-class-ref in GoogleMobileAds(flat-armv7)
"_OBJC_CLASS_$_GLKView", referenced from:
objc-class-ref in GoogleMobileAds(flat-armv7)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
 

Jack Cole

Well-Known Member
Licensed User
Use the attached h file. The updated file will also be included in v2.80 Mac builder.
Hi Erel,
I am trying to use Admob SDK v7.9.1 and the iAdmob Lib v1.32. I also downloaded the h file and copied it to the internal libraries folder.

I get the following error. I'm using the remote builder. Any ideas?

B4X:
/Users/administrator/Documents/Libs/iAdMob.h:3:9: fatal error: module 'GoogleMobileAds' not found
@import GoogleMobileAds;
~~~~~~~^~~~~~~~~~~~~~~
1 error generated.
 

Jack Cole

Well-Known Member
Licensed User
Are you using a local builder?

Have you copied GoogleMobileAds.framework to the Libs folder?

I am using the remote builder. Yes, I copied GoogleMobileAds.framework to the Libs folder. The first time I did it, I left the old version in place. When that didn't work, I deleted the old folder and re-copied it.
upload_2016-8-3_5-38-26.png
 

Jack Cole

Well-Known Member
Licensed User
The version of iAdMob included with B4i 2.80 is 1.33. Maybe you have copied an older version to the internal libraries folder?

I did copy the 1.32 over it. Just now, I reinstalled b4i. I verified that the version is 1.33 of iAdmob. I get the same error. I have included the full error below in case it might help.

B4i version: 2.80
Parsing code. (0.06s)
Compiling code. (0.26s)
Compiling layouts code. (0.04s)
Compiling debugger engine code. (4.09s)
Building Xcode project (0.07s)
Sending data to remote compiler. Error
Out: Build settings from command line:
ARCHS = armv7
CODE_SIGN_IDENTITY = iPhone
CONFIGURATION_BUILD_DIR = /Users/administrator/Documents/UploadedProjects/<user id>/Payload
OTHER_CODE_SIGN_FLAGS = --keychain <user id>
PRODUCT_NAME = Minesweeper
PROVISIONING_PROFILE = 54764be6-a182-4cc3-b6fb-52628d431a35

=== BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-all-target-headers.hmap
write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-own-target-headers.hmap
write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-project-headers.hmap
/bin/mkdir -p /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7
write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/Minesweeper.LinkFileList
write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-all-non-framework-target-headers.hmap
write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-generated-files.hmap
write-file /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper.hmap

Create product structure
/bin/mkdir -p /Users/administrator/Documents/UploadedProjects/<user id>/Payload/Minesweeper.app

ProcessInfoPlistFile Payload/Minesweeper.app/Info.plist B4iProject/B4iProject-Info.plist
cd /Users/administrator/Documents/UploadedProjects/<user id>
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"
builtin-infoPlistUtility /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/B4iProject-Info.plist -genpkginfo /Users/administrator/Documents/UploadedProjects/<user id>/Payload/Minesweeper.app/PkgInfo -expandbuildsettings -format binary -platform iphoneos -o /Users/administrator/Documents/UploadedProjects/<user id>/Payload/Minesweeper.app/Info.plist

CompileC build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_editbox.o B4iProject/b4i_editbox.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/administrator/Documents/UploadedProjects/<user id>
export LANG=en_US.US-ASCII
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 -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/lj/wrbzzxds6b53f88_rx3x7c800000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -miphoneos-version-min=7.0 -fvisibility=hidden -Wno-sign-conversion -iquote /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-generated-files.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-own-target-headers.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-all-target-headers.hmap -iquote /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Minesweeper-project-headers.hmap -I/Users/administrator/Documents/UploadedProjects/<user id>/Payload/include -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources/armv7 -I/Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/DerivedSources -F/Users/administrator/Documents/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_editbox.d --serialize-diagnostics /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_editbox.dia -c /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_editbox.m -o /Users/administrator/Documents/UploadedProjects/<user id>/build/B4iProject.build/Release-iphoneos/B4iProject.build/Objects-normal/armv7/b4i_editbox.o
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_editbox.m:2:
In file included from /Users/administrator/Documents/UploadedProjects/<user id>/B4iProject/b4i_editbox.h:7:
/Users/administrator/Documents/Libs/iAdMob.h:3:9: fatal error: module 'GoogleMobileAds' not found
@import GoogleMobileAds;
~~~~~~~^~~~~~~~~~~~~~~
1 error generated.
 

tucano2000

Active Member
Licensed User
Can you post the error message?

B4i version: 2.80
Parsing code. (0.03s)
Compiling code. (0.69s)
Compiling layouts code. (0.12s)
Compiling debugger engine code. (6.04s)
Building Xcode project (0.94s)
Sending data to remote compiler. Error
Out: Build settings from command line:
ARCHS = i386
CODE_SIGNING_REQUIRED = NO
CONFIGURATION_BUILD_DIR = /Users/tucano/Documents/macserver/UploadedProjects/<user id>/Payload
PRODUCT_NAME = result
SDKROOT = iphonesimulator10.0

=== BUILD TARGET B4iProject OF PROJECT B4iProject WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/result.hmap
write-file /Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/result-project-headers.hmap

Create product structure
/bin/mkdir -p /Users/tucano/Documents/macserver/UploadedProjects/<user id>/Payload/result.app

ProcessInfoPlistFile Payload/result.app/Info.plist B4iProject/B4iProject-Info.plist
cd /Users/tucano/Documents/macserver/UploadedProjects/<user id>
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-infoPlistUtility /Users/tucano/Documents/macserver/UploadedProjects/<user id>/B4iProject/B4iProject-Info.plist -genpkginfo /Users/tucano/Documents/macserver/UploadedProjects/<user id>/Payload/result.app/PkgInfo -expandbuildsettings -format binary -platform iphonesimulator -o /Users/tucano/Documents/macserver/UploadedProjects/<user id>/Payload/result.app/Info.plist

CompileC build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/i386/b4i_main.o B4iProject/b4i_main.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/tucano/Documents/macserver/UploadedProjects/<user id>
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.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 -x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/c2/w4lgs8wn53sd4mhpb5jjmsb40000gn/C/org.llvm.clang/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DNS_BLOCK_ASSERTIONS=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=7.0 -fvisibility=hidden -Wno-sign-conversion -Wno-infinite-recursion -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/result-generated-files.hmap -I/Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/result-own-target-headers.hmap -I/Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/result-all-target-headers.hmap -iquote /Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/result-project-headers.hmap -I/Users/tucano/Documents/macserver/UploadedProjects/<user id>/Payload/include -I/Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/DerivedSources/i386 -I/Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/DerivedSources -F/Users/tucano/Documents/macserver/UploadedProjects/<user id>/Payload -F../../Libs -MMD -MT dependencies -MF /Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/i386/b4i_main.d --serialize-diagnostics /Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/i386/b4i_main.dia -c /Users/tucano/Documents/macserver/UploadedProjects/<user id>/B4iProject/b4i_main.m -o /Users/tucano/Documents/macserver/UploadedProjects/<user id>/build/B4iProject.build/Release-iphonesimulator/B4iProject.build/Objects-normal/i386/b4i_main.o
../../Libs/GoogleMobileAds.framework/Modules/module.modulemap:2:19: error: umbrella header 'GoogleMobileAds.h' not found
umbrella header "GoogleMobileAds.h"
^
1 error generated.
In file included from /Users/tucano/Documents/macserver/UploadedProjects/<user id>/B4iProject/b4i_main.m:2:
In file included from /Users/tucano/Documents/macserver/UploadedProjects/<user id>/B4iProject/b4i_main.h:5:
/Users/tucano/Documents/macserver/Libs/iAdMob.h:3:9: fatal error: could not build module 'GoogleMobileAds'
@import GoogleMobileAds;
~~~~~~~^~~~~~~~~~~~~~~
2 errors generated.
 
Status
Not open for further replies.
Top