Since I am very new to the Mobile Application development and Stack Overflow, I have a requirement for my personal training to detect the idle time in a particular view controller of my application. I am loading a web URL in a WKWebview. So if the user spends idle time on this screen for around 3 minutes my application should logoff and come to the home screen. Went through several SO questions but all those implements a common idle time for whole application but in my case, I want only for this particular view controller. This is my view controller code for showing web URL in WKWebview:
#import "WebViewController.h"
#import <WebKit/WebKit.h>
@interface WebViewController ()<WKNavigationDelegate,WKUIDelegate>{
WKWebView *_wkViewer;
}
@end
@implementation WebViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    _wkViewer = [[WKWebView alloc] initWithFrame:CGRectMake(0,[UIApplication sharedApplication].statusBarFrame.size.height + 50, self.view.frame.size.width, self.view.frame.size.height -([UIApplication sharedApplication].statusBarFrame.size.height+70))]; 
    [_wkViewer setAutoresizingMask: UIViewAutoresizingFlexibleWidth];
    NSURL *url = [NSURL URLWithString: self.productURL];
    NSURLRequest *urlReq = [NSURLRequest requestWithURL:url
    [_wkViewer loadRequest:urlReq];
    [self.view addSubview:_wkViewer];   
}
 
-(void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    UINavigationBar *navBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0,  [UIApplication sharedApplication].statusBarFrame.size.height, self.view.frame.size.width, 50)];
    [[UINavigationBar appearance] setTitleTextAttributes:
    [NSDictionary dictionaryWithObjectsAndKeys:
    [UIColor whiteColor], NSForegroundColorAttributeName,
    [UIFont fontWithName:@"Arial" size:20.0], NSFontAttributeName,nil]];
    [navBar setAutoresizingMask: UIViewAutoresizingFlexibleWidth];
    [UINavigationBar appearance].barTintColor = [UIColor whiteColor];
    [self.view addSubview: navBar];
    UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(backClicked)]                                                                                                                                                                                     
    UINavigationItem *navigItem = [[UINavigationItem alloc] initWithTitle:_titleName];
    navigItem.leftBarButtonItem = cancelItem;
    navBar.items = [NSArray arrayWithObjects: navigItem,nil];
    [UIBarButtonItem appearance].tintColor = [UIColor whiteColor];
}
- (void)backClicked {
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
 
     
    