I'm using admob plugin (in iOS) and it work's great, but I also use google maps and I adjust the map height according to screen height minus header, and now I need to reduce the admob banner height also.
I tried to add a new function for getting banner size and call it from javascript, but I don't get any response.
This is the code I add to the CDVAdMob.m file:
- (GADAdSize)GetAdSize:(CDVInvokedUrlCommand *)command {
return self.bannerView.adSize;
}
I also had the function signature to the CDVAdMob.h file:
- (GADAdSize)GetAdSize:(CDVInvokedUrlCommand *)command;
I'm not familiar with objective c code so I don't know if what I did is correct.
In the javascript I called the new function by:
window.plugins.AdMob.createBannerView();
var size = window.plugins.AdMob.GetAdSize();
alert(size);
Can anyone tell me how it is done correctly?
Thanx
Just set the following 2 options: { overlap:false, offsetTopBar:true }, then the plugin will automatically deduct the height of status bar and the banner view.
If you are using some other forks and no such feature, try following steps.
Cordova plugin API is a void function:
And, Pass data back to javascript with:
GADAdSize is a data structure, you need convert it into a JSON object, then send back.
So, you code can be:
Mapping in AdMob.js:
Then call it in javascript: