Clicking iAd restart the whole game - ios

I am working on a sprite kit game project and I got an issue on iAd, the Ad works fine, till I not click the ad. But when i click the ad it restart my whole game, and I am using only one iAd for my entire game.
The implementation of iAd is in my UIViewController class.
I know these two methods related to my issue but I don't know how to use them:
-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
-(void)bannerViewActionDidFinish:(ADBannerView *)banner
I've tried every thing I know, but nothing comes out.

Related

AdMob, Google Mobile Ad, switching from iAd, bannerView

iOS 9.3, Xcode 7.3, ARC enabled.
I am migrating away from iAd, and I have some general questions regarding best design patterns and how to properly use the Google Mobile Ads framework for banner style ads.
How do you control presentation on ad load and load failure?
My typical approach is to start with the banner view hidden, detect when the ad is loaded, then either animate the banner view in from the top or bottom, or fade in from a stand-in image.
I noticed that GADBannerView class, does not have some of the more convenient properties of an iAd banner, such as isLoaded.
a) Right now I take advantage of the two methods - (void)adViewDidReceiveAd:(GADBannerView *)bannerView and - (void)adView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(GADRequestError *)error, set an instance variable bool for the view controller when either method gets a message, then use that variable for any additional UI changes else where. Is this a good design practice?
b) "deleted", animation works.
c) When the ad fails to load, what happens to the banner view? I notice that its alpha property is still 1.0 and that it is not hidden. In a production environment when an AdMob ad fails to load, is the banner clear? Or does it have a generic stand-in image? In other words, am I going to have to slide in an image to balance the view without the banner view there?
I've read from the basic AdMob tutorial that it doesn't really matter where the banner is, it can be in multiple view controllers, the framework will manage how these multiple banners will be filled. Could someone confirm this behavior? Say, I have two view controllers and I have two different banner views, I don't have to manage the ads? All I have to do is provide the banner view real estate?
Generally speaking, if I used to have iAd for ads and also in-app. purchases through iTunes, then what is the modern day trend? Am I supposed to have ads through AdMob and keep in-app. purchases as they are through Apple? Is that what people are doing now?
Thanks in advance for your answers. I know this maybe too general, but I really want some sort of a fundamental understanding where to head, before I submit anything to Apple.
--
Here is the code for animation I am using:
- (void)adViewDidReceiveAd:(GADBannerView *)bannerView
{
bannerDidLoad = true;
[UIView animateWithDuration:1.0 animations:^{
bannerView.alpha = 1.0;
bannerView.frame = CGRectMake(bannerView.frame.origin.x, bannerView.frame.size.height, bannerView.frame.size.width, bannerView.frame.size.height);
} completion:^(BOOL finished) {
nil;
}];
}
You should really narrow your question down. It's kind of vague. Anyways, yes GADBannerView's will be clear if they fail to receive an ad. Using the delegate methods to know what state the GADBannerView is in is the standard. Animating the alpha property should not be an issue. Not really sure what that last question is asking. You can use any ad network you'd like. If you're using in app purchases already just continue using them and remove the GADBannerView instead of the ADBannerView.

iAds and SpriteKit: SKScene Freeze on fullscreen exit on device only

My issue is similar to this one here
iAd freezes game's scene, but I feel the issue hasn't been resolved.
I have an iAd in it's own view overlayed over an SKScene so that it doesn't affect the SKScene sizing. The banner functions correctly but on fullscreen exit the SKScene is frozen. App is still receiving touch inputs, verified via NSLogs. If I click the banner again though and exit fullscreen the second time around the SKScene is no longer frozen. Why?
It's important to say that this happens only when testing on a device (iPhone5). On the simulator, there are no issues. Has anyone figured out this conundrum?
Issue is similar to this post iAD View Freezes On Ad Close but the solution: 'Remove self.canDisplayBannerAds = YES' doesn't work for me.
While I've tried creating it programatically also, I've implemented the iAd via storyboard, and this is not relevant.
The issue is also here iAd Freezes App iPhone 5[s][c] but the solution is short of superstition and still remains a mystery.
--
The alternative solution to implement an iAd with SpriteKit via self.canDisplayBannerAds and originalContentView works and functions correctly but produces a sizing/scaling issue as it shares the view with the SKScene (Spritekit iAds messing with scene size) which I'd rather avoid, but am willing to use smoke and mirrors to hide the ugly resizing animation/effect as a last resort.
--
If anyone knows the best way to implement an iAd with SpriteKit without sizing issues or freezing issues on device please let me know.

Handling iAd banner clicked in my game

I successfully added an iAd banner to my game (which plays in landscape mode), however I'm lost as to how to handle the ad being pushed. When the banner ad is pushed the game continues in the background and the player dies. Is there code to pause the game when the banner ad is clicked and resume when the ad goes away? Also when the banner ad is clicked, the ad shows up in portrait mode. Can I keep the ad in landscape mode so it is in sync with my landscape game? I'm a newbie please bear with me thanks!
You need to become the banner's delegate.
In your header file, change the #interface line by adding <ADBannerViewDelegate>, or add , ADBannerViewDelegate inside the angle brackets if you already have some. In the code where you create your banner ad, add a line like this:
self.bannerAdView.delegate = self;
Or if you're using Storyboards or IB, connect the banner ad's delegate outlet to your controller.
Once that's all done, implement these methods:
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
if (!willLeave)
{
// pause your game here
}
return YES;
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
// unpause your game
}
If your entire game is landscape, I'd recommend that you set your app to only support landscape orientations. This is done in your target settings as described in this technical note. I think that this will restrict the ads to landscape, but I've only tested that on an iPad, so it may be different on the iPhone.

my iad is still being displayed when I change from one screen to the next

I have successfully implemented iAd into my App just this past week, but when my fill rate was very low I looked into it, and I realize I have a problem. My iAd banner is correclty displayed on the first screen the user sees, and that is the only screen on which the banner ad is displayed by my design. I setup a singleton class to manage the ads, and I'm expanding it to display on additional screens in an upcoming release. However, when I push another view controller to the front that doesn't display ads, my iAd delegate methods:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
are still being called every 3 minutes as though the view is active.
Is there a way to temporarily disable iAd from trying to refresh? thanks in advance.
Since I'm not showing ads on all of the pages, I create/release the ad object when my view controller that is showing ads is displayed/not-displayed (and set the delegate to nil), and this prevents any ads/delegate functions on view controllers that are not currently displayed from being displayed.

iAd banner never gets ad in simulator

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
Always gets called... and I don’t get any ads in the simulator. Its really weird because I’ve done iAds before and they are pretty straight forward.
So far I have clean/rebuilt and downloaded the profile again. If I don’t hide it ... it shows a blank ad.
When you say "Blank ad" do you mean a black and white ad that says something along the lines of "this is a test advertisement"? If so, that's what you're supposed to see--iAd only delivers test ads to the simulator. Everything's fine :)

Resources