Can't get iad/adMob to mediate on device - ios

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.

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

Cannot present an interestitial ad while testing?

When I attempt to test AdMob's interstitial no ad is shown.
I've used the code from Google's AdMob tutorial web page.
Do I have to add a button to execute the action?
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.interstitial = [[GADInterstitial alloc] init];
self.interstitial.adUnitID = #"AdMob_Publisher_ID";
GADRequest *request = [GADRequest request];
request.testDevices = #[#"2077ef9a63d2b398840261c8221a0c9a"];// divice test number
[self.interstitial loadRequest:request];
}
You're on the right track. So far you've created the interstitial ad and have requested a test interstitial ad from AdMob. What you need to do next is present the interstitial ad. To present the interstitial ad you simply call [interstitial presentFromRootViewController:self]. After this interstitial ad is dismissed by the user you would request another interstitial ad from AdMob for the next time you wish to present an interstitial ad again. AdMob has a sample project and tutorial available showing you how to handle this and other delegate methods.

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

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];
}

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