Admob ad stuck with "You can skip this ad in 5s" - ios

I am using Admob for my iOS app. It has been going fine, but the full screen ad "GADInterstitial" sometimes produces a black screen with text "You can skip this ad in 5s". It stays the same with black screen and there is no option to skip. Any idea what could be the problem?
P.S. Access to Youtube is blocked here so is that the problem if it is a video ad?
I can see animated ads perfectly (probably gif) but sometimes this black screen gets stuck which requires minimizing the app and then switching back.
I have simply followed the code provided here
- (void) showAd
{
GADInterstitial *interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = MY_INTERSTITIAL_UNIT_ID;
[interstitial_ loadRequest:[GADRequest request]];
}
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial
{
[interstitial_ presentFromRootViewController:self];
}

Related

Pause and Resume Google Admob Banner ads when app enters background Objective c

I am using Google Admobs with ad mediations in my iOS application.
It seems like there is battery draining issue because google ads are running even when app is in background.
Is there something that i have to do to Pause google Ads when app enters background and resume when app become active.
Thanks in advance.
I have found a solution that has had mixed success for me. Hopefully someone can provide a more reliable solution. In AppDelegate.m I have this...
- (void)applicationDidEnterBackground:(UIApplication *)application {
    [self.viewController.bannerView removeFromSuperview];
    self.viewController.bannerView.delegate = nil;
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
     [self.viewController loadAdBanner];
}
This works for one of my apps. If I just call removeFromSuperview and don't set the delegate for the bannerView to nil, I still see background activity for my app when I look in the battery usage on my phone (running iOS 13.5.1). I have another app where I am doing basically the same thing but I still see background activity regardless. In both cases I am using AdMob 7.61.0.
My bannerView is declared like this:
#property(nonatomic, strong) GADBannerView *bannerView;
In MyViewController.m I have a loadAdBanner function that looks something like this...
- (void)loadAdBanner {
...
[self.bannerView setDelegate:self];
self.bannerView.rootViewController = self;
[self.view addSubview:self.bannerView];
GADRequest *request = [GADRequest request];
[self.bannerView loadRequest:request];
...
}
I hope this helps.

Admob interstitial presented whitout calling presentFromRootViewController

I'm using Admob interstitial in my app.
I followed all the guidelines and I observe Video interstitial are presented automatically while I did not call yet presentFromRootViewController.
I'm using that code to preload the interstitial :
splashInterstitial_ = [[GADInterstitial alloc] initWithAdUnitID: interstitialIdStr];
splashInterstitial_.delegate = self;
requestInterstitial = [GADRequest request];
[splashInterstitial_ loadRequest: requestInterstitial];
In the delegate, I do not present the interstitial :
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
}
I present the interstitial manually between two screens, as follow :
if (splashInterstitial_.isReady)
{
[splashInterstitial_ presentFromRootViewController: interstitialRootViewController];
self.lastInterstitialTime = [[NSDate date] timeIntervalSince1970];
return YES;
}
I placed a breakpoint on presentFromRootViewController, the breakpoint is never reached, and I can see interstitial videos presented on real device.
I sounds like the loadRequest on interstitial triggers a presentation which should not occur.
Anybody experiencing a similar issue ?
Thanks

Can't get iad/adMob to mediate on device

I'm using GoogleMobileAdsSDKiOS 7.0.0. I followed Google's AdMob instructions for setting up AdMob then I followed mediation instructions. Mediation with iAd/AdMob works well on simulator but never works on device. iAd almost never fails and when it does AdMob test banner never loads.
- (void)viewDidLoad
{
[super viewDidLoad];
self.adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 60, 320, 50)];
self.adView.delegate = self;
[self.view addSubview:adView];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
self.adView.hidden=YES;
NSLog(#"Google Mobile Ads SDK version: %#7.0.0", [GADRequest sdkVersion]);
self.adBanner_=[[GADBannerView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
self.adBanner_.adUnitID = #"my-ID";
self.adBanner_.rootViewController=self;
[self.view addSubview:self.adBanner_];
GADRequest *request =[GADRequest request];
request.testDevices = #[ #"2077ef9a63d2b398840261c8221a0c9b"];
[self.adBanner_ loadRequest:request];
}
I also tried the bannerViewDidLoadAd to show that adView loads but that only made AdMob and iAd load at the same time so I can't use bannerViewDidLoadAd.
I can't figure out why AdMob/iAd don't mediate on device yet work perfectly fine on simulator. Can't figure out why AdMob never loads test banner on device.
You should hide adview in viewDidLoad and then unhide it in bannerViewDidLoadAd. However, your code looks fine. From my experience with iad/admob mediation it takes a longer time for iAd to fail on actual device than it does on simulator. On actual device, you'll see after iAd fails then AdMob will load but i'll take time before it happens as opposed to on simulator as soon as iAd fails, AdMob loads. Not so on device. That's how i have it. Test it and wait a bit.

App freeze after iAd/google interstitial popup

I am experiencing a very weird issue with interstitials in cocos2d(version 3.1.0) This is the code I use to load both interstitials.
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {
[interstitial presentFromRootViewController:[CCDirector sharedDirector]];
interstitial.delegate = nil;
interstitial = nil;
}
- (void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
[interstitialAd presentFromViewController:[CCDirector sharedDirector]];
}
Everything seems fine and works fine until you put and hold your finger on the display before the interstitial has popped, then when you cancel the touch(release the finger) and close the popup window the app becomes unresponsive, the touch handler does not work at all and you have to restart the app. I am struggling for several hours with no success of finding the issue causer. Could it be something with the CCDirector stop and start animation methods?
I found a workaround to the bug. What I did is to disable the respond manager before the google/iAD interstitial is shown, you can see the methods below.
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {
[[[CCDirector sharedDirector]responderManager]setEnabled:false];
[interstitial presentFromRootViewController:[CCDirector sharedDirector]];
interstitial.delegate = nil;
interstitial = nil;
}
- (void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
[[[CCDirector sharedDirector]responderManager]setEnabled:false];
[interstitialAd presentFromViewController:[CCDirector sharedDirector]];
}
After that I enabled it again in the - (void) startAnimation in CCDirectorIOS.m file by putting the following code.
if (![[self responderManager]isEnabled]) {
[[self responderManager]setEnabled:true];
}
I know that this is not an elegant solution, because changing the library code directly is not always a good idea, but I could not find any other alternative. I think that this is a cocos2d bug, but I am not sure, may be someone more experienced can point out the exact issue. I have no idea if this bug is present in the newest cocos2d version.
EDIT: This behaviour is also present in the newest version.

GameCenter notification banner appears "squished" sometimes - what could be causing this?

I have an app that uses GameCenter in a very simple way (just a simple leaderboard with an all time high score). Sometimes when I switch to my app I'll see the notification saying "welcome back to Game Center" but sometimes this notification appears squished like in the following image:
http://i.imgur.com/KOCFIJo.jpg
Does anybody know what might the causing this? Because I have absolutely no idea.
My authentication code which generates the notification banner is fairly standard.
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[GKLocalPlayer localPlayer].authenticateHandler = ^(UIViewController *viewController, NSError *error) {
// If there is an error, do not assume local player is not authenticated.
if (localPlayer.isAuthenticated) {
// Enable Game Center Functionality
self.gameCenterAuthenticationComplete = YES;
[self enableGameCenter:YES];
gameCenterButton.enabled=true;
} else {
NSLog(#"game center not logged in");
// User has logged out of Game Center or can not login to Game Center, your app should run
// without GameCenter support or user interface.
self.gameCenterAuthenticationComplete = NO;
[self enableGameCenter:NO];
[self presentViewController:viewController animated:true completion:nil ];
gameCenterButton.enabled=false;
}
};
One additional piece of information is that my app is in portrait orientation when this problem occurs. It seems like if I rotate my phone 90 degrees while the banner is showing, it will look normally in landscape but in portrait it looks all squished. Does this help explain it?
I figured it out. I hadn't implemented preferredInterfaceOrientationForPresentation so I did that
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
And also I made sure that supportedInterfaceOrientations returend UIInterfaceOrientationMaskPortrait (note that it returns UIInterfaceOrientationMASKPortrait not just UIInterfaceOrientationPortrait). After that everything worked fine.
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

Resources