application:handleOpenURLメソッドの上のコメントを注意深く読むと、おそらく次のことが理解できます。
// this happens while we are running ( in the background, or from within our own app )
// only valid if Calinda-Info.plist specifies a protocol to handle
- (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;
// Patch for handleOpenURL
((MainViewController *)self.viewController).URLToHandle = URLToHandle;
[...]
}
お役に立てば幸いです。
シリル
追記:テストするときは、xcodeを停止してください。xcodeが実行されているとき、アプリケーションは例外をスローしました。xcodeを停止すると、このソリューションは正常に機能します。