iAd errors in AdBannerView - ios

I have a test application with ads only in, for testing setup. It is setup to use admob mediation service, with iAd and admob ads being sent to the device.
I am seeing the following error occurs:
[AppDeveloper]: ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=3 "The operation couldn’t be completed. Ad inventory unavailable" UserInfo=0x9f82850 {ADInternalErrorCode=3, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Ad inventory unavailable}
Strange error as I have implemented the method for didFailToReceiveAdWithError, here is my full imp code.
- (void)viewDidLoad {
[super viewDidLoad];
// Create a view of the standard size at the top of the screen.
// Available AdSize constants are explained in GADAdSize.h.
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = kAdMobPublisherID;
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
bannerView_.delegate = self;
bannerView_.backgroundColor = [UIColor blueColor];
GADRequest *request = [GADRequest request];
// Make the request for a test ad. Put in an identifier for
// the simulator as well as any devices you want to receive test ads.
request.testDevices = [NSArray arrayWithObjects:
#"4D047EB9-A3A7-441E-989E-C5437F05DB04",
#"YOUR_DEVICE_IDENTIFIER",
nil];
}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error;
{
NSLog(#"Error - did Fail to Receive an Ad");
bannerView_.hidden = YES;
}
- (void)adViewDidReceiveAd:(GADBannerView *)view;
{
NSLog(#"Ad Received");
bannerView_.hidden = NO;
}

try to put return self; at the end of the methods so the delegate receives the error

Related

How to dismiss Interstitial ad programmatically in ios

I have integrated Interstitial Ad for my iOS app successfully. And I know on that ad view there is a close button and we can dismiss it after clicking that button.
But I want to dismiss this ad view in programmatically after 3 seconds. But I don't know what is the method to dismiss this ad.
---- UPDATED-----
- (void)viewDidLoad
{
[super viewDidLoad];
singletonClassObject=[Singleton SharedManager];
//--------ADMOB FULLSCREEN----------
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.delegate = self;
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.adUnitID = #"ca-app-pub-3940256099942544/4411468910";
GADRequest *request = [GADRequest request];
// Requests test ads on simulators.
request.testDevices = #[ GAD_SIMULATOR_ID, #"MY_TEST_DEVICE_ID" ];
[self.interstitial loadRequest:request];
//--------END OF AD MOB FULLSCREEN---------
}
This is how show the ad in a click event
if ([self.interstitial isReady]) {
[self.interstitial presentFromRootViewController:self];
}
These are the delegates that fire when app dismiss,shows etc
/// Called when an interstitial ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
NSLog(#"interstitialDidReceiveAd");
}
/// Called when an interstitial ad request failed.
- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(#"interstitialDidFailToReceiveAdWithError: %#", [error localizedDescription]);
}
/// Called just before presenting an interstitial.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
NSLog(#"interstitialWillPresentScreen");
}
/// Called before the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
NSLog(#"interstitialWillDismissScreen");
//[viewAdd removeFromSuperview];
[self.view removeFromSuperview];
}
/// Called just after dismissing an interstitial and it has animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
NSLog(#"interstitialDidDismissScreen");
[self.view removeFromSuperview];
}
/// Called just before the application will background or terminate because the user clicked on an
/// ad that will launch another application (such as the App Store).
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
NSLog(#"interstitialWillLeaveApplication");
}
although undocumented, I found that interstitial can be dismissed by:
[self dismissViewControllerAnimated:YES completion:NULL];
called on the ViewController presenting the Interstitial
Backward engineering, the Interstitial must be presented by presentViewController:animated:completion:
Well Unfortunately it is not possible you can not do that.
Check out this: Cocoadocs docsets Google Mobile Ads

AdMob interstitial shown only once on iOS

I'm using admob interstitial on my iOS app.
I'm able to display the interstitial only one time, any further request to display a new interstitial fails (delegate is never called by the way).
My code is as follow:
-(void) viewDidLoad
{
[super viewDidLoad];
[self allocateAndDisplayAd];
}
-(void) allocateAndDisplayAd
{
splashInterstitial_ = [[GADInterstitial alloc] init];
splashInterstitial_.adUnitID = #"ca-app-pub-MY-ID";
splashInterstitial_.delegate = self;
GADRequest *requestInterstitial = [GADRequest request];
[splashInterstitial_ loadRequest: requestInterstitial];
}
// below functions delegate are never triggered when requesting a new interstitial !!
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
[splashInterstitial_ presentFromRootViewController: self];
}
- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error
{
splashInterstitial_ = nil;
}
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad
{
splashInterstitial_ = nil;
}
The interstitial is properly displayed when app launches (request done from the viewDidLoad), then any new request (call to allocateAndDisplayAd) fails (no error message, delegate function never called).
I tried to set splashInterstitial_ = nil; so I'm sure the next request will reallocate a new interstitial, but no way to display more than one ad.
Any help would be appreciated.
Thanks
Ok I found my issue
Any request to show interstitial from applicationWillEnterForeground will be ignored ...
And my second request was done from applicationWillEnterForeground

No ads showing admob in live iOS add

I used adMob in my iOS app. But when i test the app it shows the test ads in the simulator, but when i try to get ads on my device (Its not a developer device) then i don't get any ads. When i use my developer device i get "no ads to show". I have setup adMob used the key.
Here is my code:
-(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self datoUgeNummer];
// Initialize the banner at the bottom of the screen.
CGPoint origin = CGPointMake(0.0,
self.view.frame.size.height -
CGSizeFromGADAdSize(kGADAdSizeBanner).height);
// Use predefined GADAdSize constants to define the GADBannerView.
self.adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin];
// Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID before compiling.
self.adBanner.adUnitID = #"ca-app-pub-4641309369865580/3940179951";
self.adBanner.delegate = self;
self.adBanner.rootViewController = self;
[self.view addSubview:self.adBanner];
[self.adBanner loadRequest:[self request]];
}
-(void)dealloc {
_adBanner.delegate = nil;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
#pragma mark GADRequest generation
-(GADRequest *)request {
GADRequest *request = [GADRequest request];
// Make the request for a test ad. Put in an identifier for the simulator as well as any devices
// you want to receive test ads.
//request.testDevices = #[
// TODO: Add your device/simulator test identifiers here. Your device identifier is printed to
// the console when the app is launched.
// GAD_SIMULATOR_ID
// ];
return request;
}
#pragma mark GADBannerViewDelegate implementation
// We've received an ad successfully.
-(void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(#"Received ad successfully");
}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(#"Failed to receive ad with error: %#", [error localizedFailureReason]);
}
Do i also need Google Analytics to get adMob working ?
I hope you understand my english and can help me! :)

Crash on IOS 6.0-6.1 Ipad only Admob and iAd

I'm currently getting a crash thats holding my app out of the app store, it seems to occur when i create a google ad as a fall back for iAd.
It only occurs on the I-pad running IOS 6.0 - 6.1 in compatibility mode (the app is not universal) and it appears to occur after the:
[googleAdvertBanner loadRequest:releaseRequest];
Any help would be really appreciated, here's what i'm getting in the code view when i crash:
GADMAdNetworkConnectorImpl.m:95
0x49e008: addl $60, %esp --- Thread 1:EXEC_BAD_ACCESS (code=2, address=0xf)
The log shows the following:
DBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=3 "The operation couldn’t be completed. Ad inventory unavailable" UserInfo=0x13c9e380 {ADInternalErrorCode=3, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Ad inventory unavailable}
And my app code for the ad handling:
#pragma mark Ad Banner Delegate
#pragma mark -
- (void)bannerViewDidLoadAd:(ADBannerView *)banner{
// remove the google advert banner
[googleAdvertBanner removeFromSuperview];
// dont use auto resizing mask for constraints
advertBanner.translatesAutoresizingMaskIntoConstraints = NO;
// scroll the ad bar
[self moveViews:adView down:YES];
//NSLog(#"IAD advert has SUCCEEDED");
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
// scroll the ad bar
[self moveViews:adView down:NO];
// create the google advert
[self createGoogleAdvert];
//NSLog(#"IAD advert has FAILED");
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner{
}
#pragma mark GoogleAd Banner Delegate
#pragma mark -
- (void)adViewDidReceiveAd:(GADBannerView *)view{
// dont use auto resizing mask for constraints
googleAdvertBanner.translatesAutoresizingMaskIntoConstraints = NO;
// add the google advert banner
[adView addSubview:googleAdvertBanner];
// scroll the ad bar
[self moveViews:adView down:YES];
//NSLog(#"Google advert has SUCCEEDED");
}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error{
// remove the google ad and instantiate the apple advert
[googleAdvertBanner removeFromSuperview];
// scroll the ad bar
[self moveViews:adView down:NO];
//NSLog(#"Google advert has FAILED");
}
- (void)adViewDidDismissScreen:(GADBannerView *)adView{
}
#pragma mark Create GoogleAd Banner
#pragma mark -
- (void)createGoogleAdvert{
// if the googleadvert banner has not been initiated
if (!googleAdvertBanner) {
// create google advert banner
googleAdvertBanner = [[GADBannerView alloc]initWithAdSize:kGADAdSizeBanner];
}
// set the ads "unit identifier", delegate and root view controller
googleAdvertBanner.adUnitID = #"myid which is correct";
googleAdvertBanner.delegate = self;
googleAdvertBanner.rootViewController = self;
// test request
//GADRequest *testRequest = [GADRequest request];
//testRequest.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, #"0525457c40445ae54cac4f282ba0d409", nil];
// release request
GADRequest *releaseRequest = [GADRequest request];
// load the request
[googleAdvertBanner loadRequest:releaseRequest];
}
Try to check internet reachability before performing GADRequest. I had experience with crashing on loading adMob banners offline.
if ([[Reachability reachabilityForInternetConnection] isReachable]) {
//... banner init etc
// release request
GADRequest *releaseRequest = [GADRequest request];
// load the request
[googleAdvertBanner loadRequest:releaseRequest];
}
Ok think i solved this issue:
I had my admob mediation also serving the iAd as well as having an adbannerview, and i believe that on the lower end IOS version 6.0-6.1 When the mediated iAd failed it was unable to call the failedToLoad as the adbannerview did not exist or it was simply couldnt run the method, removing the mediation from my admob setup solved the crash.

Receiving production ads and interstitials from AdMob in test mode

I'm testing AdMob ads in my iOS-application. AdMob seems to ignore the test-flag I put in the code:
-(IBAction)quitButtonHit:(id)sender{
[[AudioPlayer sharedManager] stopSound];
[self.timer invalidate];
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = adMobUnitID;
interstitial_.delegate = self;
GADRequest *request = [GADRequest request];
request.testing = YES;
[interstitial_ loadRequest:[GADRequest request]];
}
-(void) interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error {
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void) interstitialDidDismissScreen:(GADInterstitial *)ad {
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void) interstitialDidReceiveAd:(GADInterstitial *)ad {
[ad presentFromRootViewController:self];
}
I am receiving production interstitials when I hit the Quit-button in my app. I do not understand why since Google states that they will invite you to be able to receive interstitials and because I set the test-flag on the request.
I am also receiving production ads in my app's AdMob banner. But that only goes for my device - on the simulators test ads are displayed. I also set the test-flag when requesting banners.
I would like the production ads to go away, so I won't have to worry about tapping them by accident.
I use AdMob's lates API (version 6.3.0). My deployment target is iOS 6.0.
Can anyone explain this and maybe suggest a solution to make the production ads go away?
Thanks!
Try this :
request.testDevices =
[NSArray arrayWithObjects:
// TODO: Add your device/simulator test identifiers here. They are
// printed to the console when the app is launched.
nil];

Resources