Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 597DB90C9 for ; Thu, 5 Apr 2012 00:38:33 +0000 (UTC) Received: (qmail 28951 invoked by uid 500); 5 Apr 2012 00:38:33 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 28932 invoked by uid 500); 5 Apr 2012 00:38:33 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 28925 invoked by uid 99); 5 Apr 2012 00:38:33 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2012 00:38:33 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CC6EBB129; Thu, 5 Apr 2012 00:38:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: shazron@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: ios commit: Fixed CB-444 - Xcode template new project - AppDelegate's self.invokeString usage was removed Message-Id: <20120405003832.CC6EBB129@tyr.zones.apache.org> Date: Thu, 5 Apr 2012 00:38:32 +0000 (UTC) Updated Branches: refs/heads/master 163084571 -> c397af021 Fixed CB-444 - Xcode template new project - AppDelegate's self.invokeString usage was removed Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/c397af02 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/c397af02 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/c397af02 Branch: refs/heads/master Commit: c397af021a637ebea1891c08055441aade3c0463 Parents: 1630845 Author: Shazron Abdullah Authored: Wed Apr 4 17:38:25 2012 -0700 Committer: Shazron Abdullah Committed: Wed Apr 4 17:38:25 2012 -0700 ---------------------------------------------------------------------- Cordova-based Application/Classes/AppDelegate.h | 4 +-- Cordova-based Application/Classes/AppDelegate.m | 13 +++++++---- .../Classes/MainViewController.m | 16 +++++++++++++- 3 files changed, 23 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/c397af02/Cordova-based Application/Classes/AppDelegate.h ---------------------------------------------------------------------- diff --git a/Cordova-based Application/Classes/AppDelegate.h b/Cordova-based Application/Classes/AppDelegate.h index 1051b49..71a9a8a 100644 --- a/Cordova-based Application/Classes/AppDelegate.h +++ b/Cordova-based Application/Classes/AppDelegate.h @@ -36,15 +36,13 @@ @interface AppDelegate : NSObject < UIApplicationDelegate > { - NSString* invokeString; } // invoke string is passed to your app on launch, this is only valid if you -// edit FooBar.plist to add a protocol +// edit ___PROJECTNAME___-Info.plist to add a protocol // a simple tutorial can be found here : // http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html -@property (nonatomic, copy) NSString* invokeString; @property (nonatomic, retain) IBOutlet UIWindow* window; @property (nonatomic, retain) IBOutlet CDVViewController* viewController; http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/c397af02/Cordova-based Application/Classes/AppDelegate.m ---------------------------------------------------------------------- diff --git a/Cordova-based Application/Classes/AppDelegate.m b/Cordova-based Application/Classes/AppDelegate.m index 516f440..17aff02 100644 --- a/Cordova-based Application/Classes/AppDelegate.m +++ b/Cordova-based Application/Classes/AppDelegate.m @@ -39,7 +39,7 @@ @implementation AppDelegate -@synthesize invokeString, window, viewController; +@synthesize window, viewController; - (id) init { @@ -48,8 +48,8 @@ **/ NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; - - [CDVURLProtocol registerPGHttpURLProtocol]; + + [CDVURLProtocol registerURLProtocol]; return [super init]; } @@ -62,8 +62,10 @@ - (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey]; + NSString* invokeString = nil; + if (url && [url isKindOfClass:[NSURL class]]) { - self.invokeString = [url absoluteString]; + invokeString = [url absoluteString]; NSLog(@"___PROJECTNAME___ launchOptions = %@", url); } @@ -77,6 +79,7 @@ self.viewController.useSplashScreen = YES; self.viewController.wwwFolderName = @"www"; self.viewController.startPage = @"index.html"; + self.viewController.invokeString = invokeString; self.viewController.view.frame = viewBounds; // check whether the current orientation is supported: if it is, keep it, rather than forcing a rotation @@ -112,7 +115,7 @@ } // this happens while we are running ( in the background, or from within our own app ) -// only valid if FooBar.plist specifies a protocol to handle +// only valid if ___PROJECTNAME___-Info.plist specifies a protocol to handle - (BOOL) application:(UIApplication*)application handleOpenURL:(NSURL*)url { if (!url) { http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/c397af02/Cordova-based Application/Classes/MainViewController.m ---------------------------------------------------------------------- diff --git a/Cordova-based Application/Classes/MainViewController.m b/Cordova-based Application/Classes/MainViewController.m index 1fdba1a..5e12f6d 100644 --- a/Cordova-based Application/Classes/MainViewController.m +++ b/Cordova-based Application/Classes/MainViewController.m @@ -92,15 +92,27 @@ } */ -/* Comment out the block below to over-ride */ -/* #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 + 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]; } +/* Comment out the block below to over-ride */ +/* + - (void) webViewDidStartLoad:(UIWebView*)theWebView { return [super webViewDidStartLoad:theWebView];