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.
Related
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
I load the intersitial ad on the load of the controller. When the load finished, ad starts running automatically. The sound of the ad is heard. The load code is below:
interstitial = [[GADInterstitial alloc] initWithAdUnitID:admobInterstatialID];
GADRequest *request = [GADRequest request];
[interstitial loadRequest:request];
The show ad code is below:
if ([interstitial isReady]) {
[interstitial presentFromRootViewController:self];
}
Thanks for any help!
Check logs to see if you are getting error "Cannot present interstitial. It is not ready."
Is below code written inside load of controller?
if ([interstitial isReady]) {
[interstitial presentFromRootViewController:self];
}
You need wait till ad is loaded completely ( Specially for interstitial ads).
Please change code to
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
if ([interstitial isReady]) {
[interstitial presentFromRootViewController:self];
}
}
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
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];
}
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];