1

I want to fire an action after every 10 minutes of application use.

I want to display a full screen advertisement after every 10 minutes, irrespective of where ViewController of the application is currently at.

rmaddy
  • 307,833
  • 40
  • 508
  • 550
Ahmad dar
  • 81
  • 14

2 Answers2

2

You need to use NSTimer with set the timeInterval = 10 and repeats = YES and declare this timer to your didFinishLaunchingWithOptions method. For more information you can read this official documentation of NSTimer.

And also look at How do I use NSTimer?

Community
  • 1
  • 1
iPatel
  • 43,583
  • 14
  • 113
  • 135
  • Thankyou so Much actually I was confused the NSTimer will automaticlly become invalidate when shifted to another viewcontroller. – Ahmad dar Apr 26 '14 at 06:55
  • I did it with create NSTimer with set @property and it does not invalidate when shifted to another viewcontroller. – iPatel Apr 26 '14 at 07:52
0

Try this :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        timer = [NSTimer scheduledTimerWithTimeInterval:600 target:self selector:@selector(doAction) userInfo:nil repeats:YES ];
        [pool release];
}

Hope it will help.

Mayur
  • 5,212
  • 7
  • 37
  • 65