Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed CB-444 - Xcode template new project - AppDelegate's self.invoke…

…String usage was removed
  • Loading branch information...
commit c397af021a637ebea1891c08055441aade3c0463 1 parent 1630845
@shazron shazron authored
View
4 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;
View
13 Cordova-based Application/Classes/AppDelegate.m
@@ -39,7 +39,7 @@ Licensed to the Apache Software Foundation (ASF) under one
@implementation AppDelegate
-@synthesize invokeString, window, viewController;
+@synthesize window, viewController;
- (id) init
{
@@ -48,8 +48,8 @@ - (id) init
**/
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
-
- [CDVURLProtocol registerPGHttpURLProtocol];
+
+ [CDVURLProtocol registerURLProtocol];
return [super init];
}
@@ -62,8 +62,10 @@ - (id) init
- (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 @@ - (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(
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 @@ - (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(
}
// 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) {
View
16 Cordova-based Application/Classes/MainViewController.m
@@ -92,15 +92,27 @@ - (void) registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className
}
*/
-/* 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];
Please sign in to comment.
Something went wrong with that request. Please try again.