I sorted this by setting up the polling in the initiation of the webview. The first thing to do was to set the @implementation webViewDidFinishLoad() as follows:
- (void)webViewDidFinishLoad:(UIWebView *)webView{
self->finished = true;
self->message = "";
[NSTimer scheduledTimerWithTimeInterval:0.2
target:self
selector:@selector(pollCheck)
userInfo:nil
repeats:YES
];
}
This sets the webview to call the pollCheck() method every 0.2 seconds. I added the the pollCheck method to the @implementation as follows:
-(void)pollCheck
{
self->locationURL = [webView stringByEvaluatingJavaScriptFromString:@...;"];
}
This bit executes Javascript in the browser - in this case I'm asking it to return data from instructions stored in app.data.hybrid.instruction - you can change this to execute whatever Javascript you want to use to return data.
|