Admob interstitial presented whitout calling presentFromRootViewController - ios

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

Related

Admob for iOS interstitial video runs in background when loaded

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

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.

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

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

Resources