Date/Time: 2016-06-12 15:54:31.31 +0200 Launch Time: 2016-06-12 15:48:27.27 +0200 OS Version: iOS 9.3.2 (13F69) Report Version: 105 Exception Type: 00000020 Exception Codes: 0x000000008badf00d Exception Note: SIMULATED (this is NOT a crash) Highlighted by Thread: 2 Application Specific Information: <BKNewProcess: 0x157d24200; com.my.app; pid: 6149; hostpid: -1> has active assertions beyond permitted time: {( <BKProcessAssertion: 0x157d27f70> id: 6149-C54C89BC-350A-4A17-B85C-E0E6CA9BBC4D name: Called by UIKit, from <redacted> process: <BKNewProcess: 0x157d24200; com.my.app; pid: 6149; hostpid: -1> permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:6149 preventSuspend preventIdleSleep preventSuspendOnSleep )} Elapsed total CPU time (seconds): 8.780 (user 8.780, system 0.000), 7% CPU Elapsed application CPU time (seconds): 0.488, 0% CPU Thread 2 name: GAIThread Thread 2: 0 libsystem_kernel.dylib 0x0000000180a80fd8 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x0000000180a80e54 mach_msg + 72 2 CoreFoundation 0x0000000180eb8c60 __CFRunLoopServiceMachPort + 196 3 CoreFoundation 0x0000000180eb6964 __CFRunLoopRun + 1032 4 CoreFoundation 0x0000000180de0c50 CFRunLoopRunSpecific + 384 5 Foundation 0x00000001817f0cfc -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 308 6 Foundation 0x0000000181846030 -[NSRunLoop(NSRunLoop) run] + 88 7 THD 0x00000001002c62bc 0x1000f0000 + 1925820 8 Foundation 0x00000001818d7e4c __NSThread__start__ + 1000 9 libsystem_pthread.dylib 0x0000000180b67b28 _pthread_body + 156 10 libsystem_pthread.dylib 0x0000000180b67a8c _pthread_body + 0 11 libsystem_pthread.dylib 0x0000000180b65028 thread_start + 4
if (![GameData sharedGameData].adsAreRemoved) {
[[MyAdMobController sharedController] loadBannerView];
[[MyAdMobController sharedController] loadInterstitial];
}Those methods:
- (void)loadBannerView {
if (bannerView_ != nil) {
return;
}
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait origin:CGPointMake(0, 0)];
bannerView_.adUnitID = MY_BANNER_ID;
bannerView_.rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
bannerView_.delegate = self;
[bannerView_ loadRequest:[GADRequest request]];
}
- (void)loadInterstitial {
if ( interstitial_ != nil ) {
interstitial_ = nil; //clean interstitial for reloading
}
interstitial_ = [[GADInterstitial alloc] initWithAdUnitID:MY_INTERSTITIAL_ID];
interstitial_.delegate = self;
[interstitial_ loadRequest:[GADRequest request]];
}In my main menu class:
if (![GameData sharedGameData].adsAreRemoved) {
[[MyAdMobController sharedController] addBannerToView:[CCDirector sharedDirector].view];
}And when they go from the main menu to my gameplay class:
if (![GameData sharedGameData].adsAreRemoved) {
[[MyAdMobController sharedController] removeBanner];
}- (void)addBannerToView:(UIView *)view {
if (bannerView_ != nil) {
[view addSubview:bannerView_];
}
else
{
[self loadBannerView];
}
}- (void)removeBanner {
[bannerView_ removeFromSuperview];
}In my gameplay class when they get a game over:
if (![GameData sharedGameData].adsAreRemoved) {
[[MyAdMobController sharedController] showInterstitialOnViewController:rootViewController];
}
And that method:
- (void)showInterstitialOnViewController:(UIViewController *)viewController {
if (interstitial_ != nil && [interstitial_ isReady]) {
[interstitial_ presentFromRootViewController:viewController];
}
else
{
if ([self.delegate respondsToSelector:@selector(MyInterstitialNotLoaded)]) {
[self.delegate MyInterstitialNotLoaded];
}
if (interstitial_ == nil) {
[self loadInterstitial];
}
}
}And this method gets called when the IAP is bought:
- (void)doRemoveAds {
[[MyAdMobController sharedController] removeBanner];
[GameData sharedGameData].adsAreRemoved = YES;
_removeAdsButton.enabled = NO;
}# Use: pod 'Google-Mobile-Ads-SDK' # Instead of: pod 'Firebase/Core' pod 'Firebase/AdMob'
<Google> You must set the rootViewController property of <GADBannerView: 0x1edd2f60; frame = (0 0; 320 50); clipsToBounds = YES; layer = <CALayer: 0x1edd3ed0>> before loading a request.
As you can see in my above post, I do set this property like so:
bannerView_.rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;bannerview_.rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
UINavigationController *navCon = (UINavigationController *)[UIApplication sharedApplication].delegate.window.rootViewController; bannerview_.rootViewController = [navCon.viewControllers objectAtIndex:0];