I am using Google Admobs with ad mediations in my iOS application. It seems like there is battery draining issue because google ads are running even when app is in background. Is there something that i have to do to Pause google Ads when app enters background and resume when app become active. Thanks in advance.
Asked
Active
Viewed 829 times
6
-
2I am experiencing the same issue - have you found a fix or workaround? – tipa Jun 17 '20 at 08:12
-
I am seeing something similar with an app that uses SwiftUI. When the app enters the background, I remove the banner from the content view. It seems like this may have worked, but I am not completely convinced it always does the trick. – user1248465 Jun 21 '20 at 19:02
-
I have the same issue starting from 2 weeks ago. Using the previous versions of admob didn't work so far. – Umeumeume Jun 29 '20 at 21:15
-
I am also using the same method @user1248465 suggested.. and i also do think its the right answer.. – Akhil Jul 02 '20 at 16:54
-
In android there is something like adView Pause and Resume. – Akhil Jul 02 '20 at 16:56
-
Hi. I am facing same issue with my app. Would like to know how do you know it is Admob causing issue ? – neobie Jul 15 '20 at 11:01
-
@neobie You can check it using Time Profiler Instrument – Akhil Sep 26 '20 at 21:42
-
Latest admob library (19.5.0) on Android keeps using CPU even if app is in background, after pause() and even removing/destroying the AdView! Recurring issue that was discussed over and over years ago. Keeps coming back, never fixed. I'm slowly retiring ads from my apps because of this. – 3c71 Nov 02 '20 at 17:50
1 Answers
4
I have found a solution that has had mixed success for me. Hopefully someone can provide a more reliable solution. In AppDelegate.m I have this...
- (void)applicationDidEnterBackground:(UIApplication *)application {
[self.viewController.bannerView removeFromSuperview];
self.viewController.bannerView.delegate = nil;
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[self.viewController loadAdBanner];
}
This works for one of my apps. If I just call removeFromSuperview and don't set the delegate for the bannerView to nil, I still see background activity for my app when I look in the battery usage on my phone (running iOS 13.5.1). I have another app where I am doing basically the same thing but I still see background activity regardless. In both cases I am using AdMob 7.61.0.
My bannerView is declared like this:
@property(nonatomic, strong) GADBannerView *bannerView;
In MyViewController.m I have a loadAdBanner function that looks something like this...
- (void)loadAdBanner {
...
[self.bannerView setDelegate:self];
self.bannerView.rootViewController = self;
[self.view addSubview:self.bannerView];
GADRequest *request = [GADRequest request];
[self.bannerView loadRequest:request];
...
}
I hope this helps.

user1248465
- 224
- 3
- 6
-
1I can confirm it works for me. Instead of overriding the AppDelegate methods, one can subscribe to didEnterBackgroundNotification in the controller itself. – epx Jul 14 '20 at 02:24