iOS Question Admob - Adaptive banners

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. If using local builder update to GoogleMobileAds v7.52: https://developers.google.com/admob/ios/download
Don't update GoogleAppMeasurement.framework for now.
The hosted builders were updated.

2.
B4X:
#if OBJC
- (NSArray *)GetAdaptiveSize:(float)width {
   GADAdSize g = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(width);
   CGSize s = g.size;
   return @[[NSValue valueWithBytes: &g
               objCType:@encode(GADAdSize)], @(s.width), @(s.height)];
}
#End If

3.
B4X:
'example of adding AdView in AppStart:
If Page1.RootPanel.Width = 0 Then
   Wait For Page1_Resize (Width As Float, Height As Float)
End If
Dim no As NativeObject = Me
Dim sizes As List = no.RunMethod("GetAdaptiveSize:", Array(Page1.RootPanel.Width))
ad.Initialize("ad", "ca-app-pub-1267570815929340/4744679717", Page1, sizes.Get(0))
Dim w As Float = sizes.Get(1) 'ignore
Dim h As Float = sizes.Get(2)
Page1.RootPanel.AddView(ad, 0, 0, Page1.RootPanel.Width, h)
 
Last edited:
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
As per documentation:
The Google Mobile Ads SDK returns an optimized ad height for the given width in a GADAdSize.
Anchored banner height is never larger than 15% of the device's height and never smaller than 50 points.
height is variable from device to device, not fixed.

In this code height is fixed on 60 points
B4X:
Page1.RootPanel.AddView(ad, 0, 0, Page1.RootPanel.Width, 60)
I didn't test this code, maybe I'm wrong but will not be good on iPad, and on devices where height will be 50 points.
 
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Framework is upgraded. I saw the message late. It seems that everything is working normally. Do I need to do something more?
 
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
I'm using xCode 10.3. I have a lot of problems with xCode 11, and I have some emergency projects, so I'm using xCode 10.3.
 
Upvote 0
Top