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
  • 314,917
  • 42
  • 532
  • 579
Ahmad dar
  • 81
  • 1
  • 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
  • 46,010
  • 16
  • 115
  • 137
  • 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 Prajapati
  • 5,454
  • 7
  • 41
  • 70