mopub/mopub-client — Issue #31: MPAdView ignoresAutorefresh problem
Author: plarsson
Created: 2012-02-23 11:33:16+00:00
State: open

I have a problem when trying to pause/resume the MPAdView, using ignoresAutorefresh property. The problem occurs when I'm trying to resume the ads (ignoresAutorefresh=YES). The ads never resumes, It seems that the NSTimer is invalidated.

The only way to get it working again is to request a new ad, which I don't want in this case.

However I tried to revert to an older revision of the code which actually pausing instead of invalidating and that solved the problem. Is there any other way achieve pause/resume without refreshing with a new ad ?

diff --git a/MoPubiOS/MoPubSDK/MPAdManager.m b/MoPubiOS/MoPubSDK/MPAdManager.m
index bea8b3f..d1add0d 100644
--- a/MoPubiOS/MoPubSDK/MPAdManager.m
+++ b/MoPubiOS/MoPubSDK/MPAdManager.m
@@ -345,12 +345,21 @@ NSString * const kAdTypeMraid = @"mraid";

- (void)setIgnoresAutorefresh:(BOOL)ignoresAutorefresh
{
- _ignoresAutorefresh = ignoresAutorefresh;
-
- if (_ignoresAutorefresh) [self cancelPendingAutorefreshTimer];
- else [self scheduleAutorefreshTimerIfEnabled];
+ _ignoresAutorefresh = ignoresAutorefresh;
+
+ if (_ignoresAutorefresh)
+ {
+ MPLogInfo(@"Ad view (%p) is now ignoring autorefresh.", self);
+ if ([self.autorefreshTimer isScheduled]) [self.autorefreshTimer pause];
+ }
+ else
+ {
+ MPLogInfo(@"Ad view (%p) is no longer ignoring autorefresh.", self);
+ if ([self.autorefreshTimer isScheduled]) [self.autorefreshTimer resume];
+ }
}

+
- (void)rotateToOrientation:(UIInterfaceOrientation)orientation
{
if (self.currentAdapter) {