简体   繁体   中英

How to show Rate us Dialog by Detecting time spend in Separate Screens in Xcode7

I have developed and deployed my app in AppStore. It is running successfully.

Now I have a Logical issue while implementing a Rate us Dialog.

I want to show a Custom dialog box when user has spend 5 mins in my App and 30 Seconds in any Screen.

Curently the only solution which comes in my mind is use of:

performSelector:withObject:afterDelay:

But I am not sure it is good or not. Is their any other way to achieve this.

Edit :

I have Implemented this piece of code in ApplicationDidFinishLaunching:

    self.timerForScreenTimeOut =  [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(idleTimerExceeded) userInfo:nil repeats:YES];

Now How can I detect How many seconds elapsed in Particular screen before poping it out from Navigation Controller .

you can call your method inside applicationWillEnterForeground:.
For example: dispatch_async(dispatch_get_main_queue(), ^{
                NSTimer *rateTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0
                                                                   target: self
                                                                 selector: @selector(showRatePrompt)
                                                                 userInfo: nil repeats:YES];
            });

To detect the time elapsed in Screen

In viewdidlod

- (void)viewDidLoad {
   [super viewDidLoad];

    //create Global variable of NSInteger *seconds and initialise it with 0
    seconds = 0;

    NSTimer *Secondtimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(increaseTimeCount) userInfo:nil repeats:YES];
    [Secondtimer fire];
}

And in your increaseTimeCount method, increase the seconds.

- (void)increaseTimeCount {
    seconds++;
}

So when seconds value will reach to 30, then you can show your alert and invalidate the timer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM