: handleOpenURL, , , :
- (BOOL) application:(UIApplication*)application handleOpenURL:(NSURL*)url
, . , :
MainViewController.h
@interface MainViewController : CDVViewController
@property (nonatomic, retain) NSString *URLToHandle;
@end
MainViewController.m
- (void) webViewDidFinishLoad:(UIWebView*) theWebView
{
if (self.URLToHandle)
{
NSString* jsString = [NSString stringWithFormat:@"window.setTimeout(function() {handleOpenURL(\"%@\"); },1);", self.URLToHandle];
[theWebView stringByEvaluatingJavaScriptFromString:jsString];
}
[...]
}
- (void)dealloc
{
self.URLToHandle = nil;
[super dealloc];
}
@synthesize URLToHandle;
AppDelegate.m
- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
[...]
self.viewController = [[[MainViewController alloc] init] autorelease];
self.viewController.useSplashScreen = YES;
self.viewController.wwwFolderName = @"www";
self.viewController.startPage = @"index.html";
self.viewController.view.frame = viewBounds;
((MainViewController *)self.viewController).URLToHandle = URLToHandle;
[...]
}
, .
: , xcode. xcode , . xcode, .