Question

I am using ads from RevMob in an app I am developing, what I am wondering is how I can show a fullscreen ad every 5. app opening. I can't figure out how to do this, and I didn't find anything about this on the web. Thanks for helping!

The current code I am using is in AppDelegate.m:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

[RevMobAds session].parallaxMode = RevMobParallaxModeOff;
        [[RevMobAds session] showFullscreen];
}
Was it helpful?

Solution

Use NSUserDefaults to store the amount of times the app has been opened, and increment it everytime in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Then do whatever you want to do whenever its been opened 5 times :]

Ex:

NSInteger timesLaunched = [[NSUserDefaults standardUserDefaults] integerForKey:@"timeslaunched"]
timesLaunched++
[[NSUserDefaults standardUserDefaults] setInteger:timesLaunched forKey:@"timeslaunched];

if (timesLaunched % 5 == 0) {
  // Show Ads
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top