incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: Fixed CB-444 - Xcode template new project - AppDelegate's self.invokeString usage was removed
Date Thu, 05 Apr 2012 00:38:32 GMT
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 <shazron@apache.org>
Authored: Wed Apr 4 17:38:25 2012 -0700
Committer: Shazron Abdullah <shazron@apache.org>
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];


Mime
View raw message