0

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];
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
ThomasGulli
  • 604
  • 1
  • 7
  • 20
  • 4
    Please don't do this. Think of your users. I recently purged one of my more useful apps because they started doing this. – rmaddy Feb 12 '14 at 16:26
  • Instead of every 5x launched maybe once every day or so? – CokePokes Feb 12 '14 at 16:29
  • 1
    Agree with @rmaddy. Ads are OK, but they should be shown at some minimally intrusive time, not at app launch. Every 5 document saves, after a level is beat, etc. – Aaron Brager Feb 12 '14 at 16:32
  • You got a point @rmaddy , I hate when other developers uses to much and annoying ads in apps - so I don't think I will do this. – ThomasGulli Feb 12 '14 at 16:37

1 Answers1

2

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
}
Jack
  • 16,677
  • 8
  • 47
  • 51