Admobs ad only shows on the simulator - ios

I've having issues with creating an admob ad which will be shown on the simulator and the device. At the moment i't will only show on the simulator. Here i get an ad which say: PUBLISHER TEST AD.
I've searched for sometime, but cant find an solution
Why wont it show on the device as well?
- (void)viewDidLoad
{
self.bannerView = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height-50, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)];
self.bannerView.adUnitID = myAdUnitID;
self.bannerView.delegate = self;
[self.bannerView setRootViewController:self];
[self.view addSubview:self.bannerView];
[self.bannerView loadRequest:[self createRequest]];
[self.navigationController.tabBarController.tabBar setHidden:YES];
}
-(GADRequest *)createRequest {
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
return request;
}
-(void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(#"Ad Received");
[UIView animateWithDuration:1.0 animations:^{
adView.frame = CGRectMake(0.0, self.view.frame.size.height-50, adView.frame.size.width, adView.frame.size.height);
}];
}
-(void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(#"error due to: %#", [error localizedFailureReason]);
}

Admobs ad only shows on the simulator
Because You Added GAD_SIMULATOR_ID in this line of code so it showing only testing ads on simulator.
[NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
So my opinion is you can test on device as if you add your device id in this array.So every time when you open this app this will show you test add and as soon possible if add available on Google Admob this will show you the ad and start showing Impression on your Admob account.

Related

IOS Google admob appdelegate code is deprecated for splash interstitial

I am using IOS Google Admob SDK 6.11.1 and Xcode 5.1.
If I thought loadrequest is replacement for loadanddisplayrequest but its not.
[splashInterstitial_ loadRequest:[GADRequest request]];
Because intertitial never appears by using loadrequest only.
loadAndDisplayRequest this method is working but I want to know whats the replacement for this deprecated method.
You need to call presentFromRootViewController: after you've received the interstitial:
#pragma mark - GADInterstitialDelegate
- (void)interstitialDidReceiveAd:(DFPInterstitial *)ad
{
[splashInterstitial_ presentFromRootViewController:self];
}
Use this code in appdelegate .it's working for me.
- (void)applicationDidBecomeActive:(UIApplication *)application
{
GADRequest *request = [GADRequest request]; // here you need to crate object of GADRequest
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID =#"ca-app-pub-43434/343434";
interstitial_.delegate = self;
// request.testDevices = [NSArray arrayWithObjects:
// #"MY_SIMULATOR_IDENTIFIER",
// #"fbb99fa8c725017137fb191a20aa342491b82a37",
// nil];
[interstitial_ loadRequest:request];
}
- (void)interstitial:(GADInterstitial *)interstitial
didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(#"==%#",[error localizedDescription]);
}
-(void)interstitialWillPresentScreen:(GADInterstitial *)ad{
NSLog(#"on screen");
}
- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {
// [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
[interstitial presentFromRootViewController:self.window.rootViewController];
// [interstitial presentFromRootViewController:self];
}

admob interstitial iOS testing?

i want to be able to request interstitial test ads on iOS on the simulator
this is the code I'm using
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = #"XXXXXXXXXXXXXXXX";
[interstitial_ loadRequest:[GADRequest request]];
interstitial_.delegate = self;
thanks.
Not sure about your specific question. But, the Google Mobile Ads SDK documentation is very rich. Here's the code which I often use -
- (void)loadAdMobIntersBanner
{
interstitial_ = [[GADInterstitial alloc] init];
interstitial_.adUnitID = #"ca-app-pub-xxxxxxxxx/xxxxxxx";
interstitial_.delegate = self;
GADRequest *request = [GADRequest request];
[interstitial_ loadRequest:request];
}
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
[interstitial_ presentFromRootViewController:self];
}

Crash while presenting a view controller after closing Google Mobile Ads Splash Interstitial

iOS App is crashing, if we try to present a view after dismissing the Google Mobile Ads Splash Interstitial.
Simulator Version : iOS 7.1(4 inch 64 bit)
Google Mobile Ads SDK Version : 6.9.2
Code for presenting splash ad(application:didFinishLaunchingWithOptions:) :
InitialSlidingViewController *controller = [[InitialSlidingViewController alloc] init];
[self.window setRootViewController:controller];
splashInterstitial_ = [[DFPInterstitial alloc] init];
splashInterstitial_.adUnitID = SplashInterstitialID;
GADRequest *request = [GADRequest request];
splashInterstitial_.delegate = self;
request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
[splashInterstitial_ loadAndDisplayRequest:request
usingWindow:window_
initialImage:[UIImage imageNamed:imageName]];
[self.window setBackgroundColor:[UIColor blackColor]];
[self.window makeKeyAndVisible];
Delegate Methods used
- (void)interstitial:(DFPInterstitial *)interstitial didFailToReceiveAdWithError:(GADRequestError *)error {
//present a view
}
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
ad.delegate = nil;
splashInterstitial_.delegate = nil;
ad = nil;
splashInterstitial_ = nil;
//Present a view controller
}
Code used for presenting view
NewViewController *newVC = [[NewViewController alloc] initWithNibName:#"NewViewController" bundle:nil];
UINavigationController *nav = [[PortraitNavController alloc] initWithRootViewController:newVC];
nav.navigationBarHidden = YES;
[self.navigationController presentViewController:nav animated:YES completion:nil];
//Crash Log from console:
* -[GADWebAppViewController isKindOfClass:]: message sent to deallocated instance 0x573efe90
Solved this issue by moving the code for presenting interstitial to Rootviewcontroller. This solution is recommended in Google Ads Developer official blog.
//MyRootViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
// Remember whether the status bar was hidden or not.
hideStatusBar_ = [UIApplication sharedApplication].statusBarHidden;
splashInterstitial_ = [[DFPInterstitial alloc] init];
splashInterstitial_.adUnitID = SplashInterstitialID;
splashInterstitial_.delegate = self;
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
[splashInterstitial_ loadRequest:request];
}
#pragma mark - splashInterstitial delegate methods
- (void)restoreController {
if (imageView_ != nil) {
[imageView_ removeFromSuperview];
}
[UIApplication sharedApplication].statusBarHidden = hideStatusBar_;
}
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
[splashInterstitial_ presentFromRootViewController:self];
}
- (void)interstitial:(DFPInterstitial *)interstitial didFailToReceiveAdWithError:(GADRequestError *)error {
[self restoreController];
}
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
[self restoreController];
}
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
//Dismiss Delegate
}
imageView_ is a full screen image view contains the same splash screen image.

Failed to receive Google Mobile adds

I am unable to receive mobile adds in my app.
My code is here:-
-(void) createMObAdds
{
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
// Specify the ad unit ID.
bannerView_.adUnitID = #"d81cb38a93cc479";
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
}
- (GADRequest *)request
{
GADRequest *request = [GADRequest request];
request.testDevices = #[GAD_SIMULATOR_ID];
[request setTesting:YES];
return request;
}
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(#"Received ad successfully");
}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(#"Failed to receive ad with error: %#", [error localizedFailureReason]);
}
But I am getting ERROR :Request Error: A network error occurred.
Please let me know where is the problem in my code or what I need to do ?.
Please see below Google Developer Link which guide you step by step
Google Developer AdMob Guide
hope it Help full to you

How to fix GADDelegateManager didYouNilOutYourDelegate:selector: error

I am using Admob in my app.
I am getting following error:
[GADDelegateManager didYouNilOutYourDelegate:selector:] at GADDelegateManager.m:48
I am releasing my Admob Banner object in dealloc.
Can anyone tell what can be the possible fix for this error.
-(void)displayAds {
self.aBannerView.adUnitID = AdmobPublisherID;
[self.aBannerView setDelegate:self];
[self.aBannerView setRootViewController:roorViewController];
if (isAdLoaded) {
[self.view addSubview:self.aBannerView];
} else {
// Initiate a generic request to load it with an ad.
[self.view addSubview:self.aBannerView];
[self.aBannerView loadRequest:[self createRequest]];
isAdLoaded = YES;
}
}
#pragma mark GADRequest generation
- (GADRequest *)createRequest {
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects: nil];
return request;
}
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(#"Received ad successfully popup");
if(self.aBannerView !=nil) {
self.aBannerView.hidden = NO;
}
}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(#"Failed to receive ad with error: %#", [error localizedFailureReason]);
[self.aBannerView removeFromSuperview];
[self showInhouseAd];
}
- (void)adViewWillLeaveApplication:(GADBannerView *)bannerView {
}
- (void)dealloc {
[aBannerView release];
}
Thanks,
The selector name seems rather explanatory to me. Try setting the delegate to nil before releasing the banner view:
- (void)dealloc {
[aBannerView setDelegate:nil];
[aBannerView release];
}
As the error actually says [GADDelegateManager didYouNilOutYourDelegate:selector:]. I would actually try
- (void)dealloc
{
aBannerView.delegate = nil;
[aBannerView release];
}
That seems like your problem as indicated by the error message.

Resources