Reputation: 10039
I am using Phonegap2.1. I have the webViewDidFinishLoad method in my AppDelegate.m file. It used to get called by its own in previous phonegap versions. Now, it does not get called at all. Do I need to assign the delegate somewhere?
- (void)webViewDidFinishLoad:(UIWebView *)theWebView
{
if(self.invokeString)
{
// this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
[theWebView stringByEvaluatingJavaScriptFromString:jsString];
}
// Black base color for background matches the native apps
theWebView.backgroundColor = [UIColor blackColor];
return [ self.viewController webViewDidFinishLoad:theWebView ];
}
Upvotes: 3
Views: 1263
Reputation: 2916
When you upgrade to 2.1.0, it is recommended that you comment out all that section because it is deprecated. The code you supplied does not actually help you in any way when using cordova 2.1.0 so if you comment it out, your app should work just fine.
#pragma UIWebDelegate implementation
/*
- (void) webViewDidFinishLoad:(UIWebView*) theWebView
{
// only valid if ___PROJECTNAME__-Info.plist specifies a protocol to handle
if (self.invokeString)
{
// this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
NSLog(@"DEPRECATED: window.invokeString - use the window.handleOpenURL(url) function instead, which is always called when the app is launched through a custom scheme url.");
NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
[theWebView stringByEvaluatingJavaScriptFromString:jsString];
}
// Black base color for background matches the native apps
theWebView.backgroundColor = [UIColor blackColor];
return [super webViewDidFinishLoad:theWebView];
}*/
Leaving this section uncommented gives this warning:
Classes/MainViewController.m:133:11: 'invokeString' is deprecated
Classes/MainViewController.m:137:86: 'invokeString' is deprecated
Your app will run fine only it is not ideal to be releasing products that have warnings.
Unless if you deliberately did not put your code for the whole world to see
[CB-853] Deprecate window.invokeString
- use window.handleOpenURL(url)
instead
Upvotes: 1