Sybase Unwired Platform comes with PhoneGap 1.4.1 libraries linked in; to upgrade to a later version of the PhoneGap library used by the Hybrid Web Container, perfom these steps.
The PhoneGap library that is included with the Hybrid Web Container uses source code that has been modified slightly from the source available from PhoneGap, mainly because the original source does not support some Hybrid Web Container user interface.
Beginning with PhoneGap 1.5.0, PhoneGap rebranded the name PhoneGap to Cordova, which means that when you upgrade, changes to internal class names must be updated.
In addition to the name change, version 1.5.0 ushered in a reorganization of core classes in the PhoneGap implementation. Because of the coupling between the Hybrid Web Container UI code and PhoneGap classes, upgrading requires a careful replacement of the existing PhoneGap integration.
#if 0 -(void) createGapView; #endif
-(void) reset; -(void)setTheWebView: (UIWebView*) theWebView; -(void)setTheViewController: (UIViewController*) theViewController;
#if 0 // read from Cordova.plist in the app bundle NSString* appPlistName = @"Cordova"; NSDictionary* cordovaPlist = [[self class] getBundlePlist:appPlistName]; if (cordovaPlist == nil) { NSLog(@"WARNING: %@.plist is missing.", appPlistName); return; } self.settings = [[[NSDictionary alloc] initWithDictionary:cordovaPlist] autorelease]; // read from Plugins dict in Cordova.plist in the app bundle NSString* pluginsKey = @"Plugins"; NSDictionary* pluginsDict = [self.settings objectForKey:@"Plugins"]; if (pluginsDict == nil) { NSLog(@"WARNING: %@ key in %@.plist is missing! Cordova will not work, you need to have this key.", pluginsKey, appPlistName); return; } // set the whitelist self.whitelist = [[[CDVWhitelist alloc] initWithArray:[self.settings objectForKey:@"ExternalHosts"]] autorelease]; self.pluginsMap = [pluginsDict dictionaryWithLowercaseKeys]; #endif
#if 0 NSString* startFilePath = [self pathForResource:self.startPage]; NSURL* appURL = nil; NSString* loadErr = nil; if (startFilePath == nil) { loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", self.wwwFolderName, self.startPage]; NSLog(@"%@", loadErr); self.loadFromString = YES; appURL = nil; } else { appURL = [NSURL fileURLWithPath:startFilePath]; } [ self createGapView]; #endif
#if 0 if (!loadErr) { NSURLRequest *appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0]; [self.webView loadRequest:appReq]; } else { NSString* html = [NSString stringWithFormat:@"<html><body> %@ </body></html>", loadErr]; [self.webView loadHTMLString:html baseURL:nil]; } #endif
#if 0 - (void) createGapView { CGRect webViewBounds = self.view.bounds; webViewBounds.origin = self.view.bounds.origin; if (!self.webView) { self.webView = [[ [ CDVCordovaView alloc ] initWithFrame:webViewBounds] autorelease]; self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); [self.view addSubview:self.webView]; [self.view sendSubviewToBack:self.webView]; self.webView.delegate = self; } } #endif
if ([obj isKindOfClass:[CDVPlugin class]] && [obj respondsToSelector:@selector(setViewController:)]) { [obj setViewController:self.viewController]; }
-(void) reset { [self onAppWillTerminate:nil]; self.pluginObjects = nil; self.webView = nil; self.commandDelegate = nil; self.view = nil; }
-(void) setTheWebView: (UIWebView*) theWebView { self.webView = theWebView; }
-(void) setTheViewController: (UIViewController *)theViewController { self.viewController = (CDVViewController*)theViewController; }
if (self.viewController != nil) { self.viewController = nil; }
[[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];
This causes the connection plug-in object to remove itself as an observer for all of these events when a Workflow application is closed, rather than only for specified events. This is necessary because during initialization, Cordova creates a CDVConnection object, then adds this object as an observer to NSNotificationCenter. It adds itself as the callback delegate for online/offline connection events, as well as for background/foreground processing notifications. The Hybrid Web Container implementation of Cordova is somewhat nonstandard, in that it expects Cordova to initialize and de-initialize when a Workflow application is opened and closed. If the observers are left, they remain even after the Workflow application is closed, and may cause memory issues.
@protocol MissingFeaturesProvider <NSObject> - (void) requestContactsAccess; @end
+ (void) setContactsAccessDelegate: (id<MissingFeaturesProvider>)accessProvider;
static id<MissingFeaturesProvider> s_contactsAccessDelegate = nil;
if (s_contactAccessDelegate != nil) { [s_contactsAccessDelegate requestContactsAccess]; }
+ (void) setContactsAccessDelegate:(id<MissingFeaturesProvider>)accessProvider { s_contactsAccessDelegate = accessProvider; }
[aContact release]; CFRelease(addrBook);
[aContact release]; if (addrBook != nil) { CFRelease(addrBook); }