From 85e4e5326e79c5f5304a25e31f129b69ed647a8d Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Sat, 11 Feb 2017 18:05:03 -0500 Subject: [PATCH] various fixes for the odd "no connection" issue --- config.xml | 7 +- hooks/before_prepare/01_pp_hacks.sh | 38 ++++----- www/external/AppDelegate.m | 124 ++-------------------------- www/index.html | 2 +- www/js/LoginCtrl.js | 3 + www/js/app.js | 5 ++ 6 files changed, 37 insertions(+), 142 deletions(-) diff --git a/config.xml b/config.xml index fee60f370..b504e1e4f 100644 --- a/config.xml +++ b/config.xml @@ -8,10 +8,11 @@ Pliable Pixels - + - + + @@ -97,6 +98,6 @@ - + diff --git a/hooks/before_prepare/01_pp_hacks.sh b/hooks/before_prepare/01_pp_hacks.sh index 1a5334064..0d0317414 100755 --- a/hooks/before_prepare/01_pp_hacks.sh +++ b/hooks/before_prepare/01_pp_hacks.sh @@ -27,13 +27,13 @@ else echo "Directory platforms/android does not exist, skipping..." fi -echo "Copying plist hack for iOS for non SSL connections" -echo "--------------------------------------------------" -if [ -d "platforms/ios/zmNinja" ]; then - exe cp www/external/zmNinja-Info.plist.IOS9nonSSLPatch platforms/ios/zmNinja/zmNinja-Info.plist -else - echo "Directory platforms/ios/zmNinja does not exist, skipping..." -fi +#echo "Copying plist hack for iOS for non SSL connections" +#echo "--------------------------------------------------" +#if [ -d "platforms/ios/zmNinja" ]; then +# exe cp www/external/zmNinja-Info.plist.IOS9nonSSLPatch platforms/ios/zmNinja/zmNinja-Info.plist +#else +# echo "Directory platforms/ios/zmNinja does not exist, skipping..." +#fi echo "Copying Android notification icons to resource dir" echo "--------------------------------------------------" @@ -43,18 +43,18 @@ else echo "Directory platforms/android/res/ does not exist, skipping..." fi -#echo "Fixing insecure SSL permission problem" -#echo "--------------------------------------------------" -#if [ -d "platforms/android/CordovaLib/src/org/apache/cordova/engine" ]; then -# exe cp www/external/SystemWebViewClient.java platforms/android/CordovaLib/src/org/apache/cordova/engine -#else -# echo "Directory platforms/android/CordovaLib/src/org/apache/cordova/engine does not exist, skipping..." -#fi -#if [ -d "platforms/ios/zmNinja/Classes" ]; then -# exe cp www/external/AppDelegate.m platforms/ios/zmNinja/Classes/ -#else -# echo "Directory platforms/ios/zmNinja/Classes does not exist, skipping..." -#fi +echo "Fixing insecure SSL permission problem" +echo "--------------------------------------------------" +if [ -d "platforms/android/CordovaLib/src/org/apache/cordova/engine" ]; then + exe cp www/external/SystemWebViewClient.java platforms/android/CordovaLib/src/org/apache/cordova/engine +else + echo "Directory platforms/android/CordovaLib/src/org/apache/cordova/engine does not exist, skipping..." +fi +if [ -d "platforms/ios/zmNinja/Classes" ]; then + exe cp www/external/AppDelegate.m platforms/ios/zmNinja/Classes/ +else + echo "Directory platforms/ios/zmNinja/Classes does not exist, skipping..." +fi diff --git a/www/external/AppDelegate.m b/www/external/AppDelegate.m index 0b13600a8..3b5c47fa0 100644 --- a/www/external/AppDelegate.m +++ b/www/external/AppDelegate.m @@ -28,133 +28,19 @@ Licensed to the Apache Software Foundation (ASF) under one #import "AppDelegate.h" #import "MainViewController.h" -#import - @implementation AppDelegate -@synthesize window, viewController; - -- (id)init -{ - /** If you need to do any extra app-specific initialization, you can do it here - * -jm - **/ - NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; - - [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; - - int cacheSizeMemory = 8 * 1024 * 1024; // 8MB - int cacheSizeDisk = 32 * 1024 * 1024; // 32MB -#if __has_feature(objc_arc) - NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"]; -#else - NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease]; -#endif - [NSURLCache setSharedURLCache:sharedCache]; - - self = [super init]; - return self; -} - -#pragma mark UIApplicationDelegate implementation - -/** - * This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up) - */ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { - CGRect screenBounds = [[UIScreen mainScreen] bounds]; - -#if __has_feature(objc_arc) - self.window = [[UIWindow alloc] initWithFrame:screenBounds]; -#else - self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease]; -#endif - self.window.autoresizesSubviews = YES; - -#if __has_feature(objc_arc) - self.viewController = [[MainViewController alloc] init]; -#else - self.viewController = [[[MainViewController alloc] init] autorelease]; -#endif - - // Set your app's start page by setting the tag in config.xml. - // If necessary, uncomment the line below to override it. - // self.viewController.startPage = @"index.html"; - - // NOTE: To customize the view's frame size (which defaults to full screen), override - // [self.viewController viewWillAppear:] in your view controller. - - self.window.rootViewController = self.viewController; - [self.window makeKeyAndVisible]; - - return YES; -} - -// this happens while we are running ( in the background, or from within our own app ) -// only valid if zmNinja-Info.plist specifies a protocol to handle -- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation -{ - if (!url) { - return NO; - } - - // all plugins will get the notification, and their handlers will be called - [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; - - return YES; -} - -// repost all remote and local notification using the default NSNotificationCenter so multiple plugins may respond -- (void) application:(UIApplication*)application - didReceiveLocalNotification:(UILocalNotification*)notification -{ - // re-post ( broadcast ) - [[NSNotificationCenter defaultCenter] postNotificationName:CDVLocalNotification object:notification]; -} - -#ifndef DISABLE_PUSH_NOTIFICATIONS - - - (void) application:(UIApplication*)application - didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken - { - // re-post ( broadcast ) - NSString* token = [[[[deviceToken description] - stringByReplacingOccurrencesOfString:@"<" withString:@""] - stringByReplacingOccurrencesOfString:@">" withString:@""] - stringByReplacingOccurrencesOfString:@" " withString:@""]; - - [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotification object:token]; - } - - - (void) application:(UIApplication*)application - didFailToRegisterForRemoteNotificationsWithError:(NSError*)error - { - // re-post ( broadcast ) - [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotificationError object:error]; - } -#endif - -- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window -{ - // iPhone doesn't support upside down by default, while the iPad does. Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected). - NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown); - - return supportedInterfaceOrientations; -} - -- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application -{ - [[NSURLCache sharedURLCache] removeAllCachedResponses]; + self.viewController = [[MainViewController alloc] init]; + return [super application:application didFinishLaunchingWithOptions:launchOptions]; } @end -// credit: http://ivancevich.me/articles/ignoring-invalid-ssl-certificates-on-cordova-android-ios/ - @implementation NSURLRequest(DataController) -+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host + + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host { - return YES; + return YES; } -@end +@end diff --git a/www/index.html b/www/index.html index 7da97e389..3ba46aa2a 100644 --- a/www/index.html +++ b/www/index.html @@ -4,7 +4,7 @@ - + diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index 5424dbd48..300e4fbf5 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -638,9 +638,12 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r // lets logout NVRDataModel.debug("Logging out of current session..."); $rootScope.authSession = "undefined"; + + $http( { method: 'POST', + timeout:10000, //withCredentials: true, url: $scope.loginData.url + '/index.php', headers: diff --git a/www/js/app.js b/www/js/app.js index f7bc5e696..9d8e49942 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -623,6 +623,7 @@ angular.module('zmApp', [ .factory('timeoutHttpIntercept', ['$rootScope', '$q', 'zm', '$injector', function($rootScope, $q, zm, $injector) { $rootScope.zmCookie = ""; + //console.log ("HHHHHHHHHHHHHH**************************"); return { @@ -1514,6 +1515,8 @@ angular.module('zmApp', [ $rootScope.platformOS = "desktop"; NVRDataModel.log("Device is ready"); + + // var ld = NVRDataModel.getLogin(); if ($ionicPlatform.is('ios')) $rootScope.platformOS = "ios"; @@ -1821,6 +1824,8 @@ angular.module('zmApp', [ NVRDataModel.log("Setting up POST LOGIN timer"); zmAutoLogin.start(); setupPauseAndResume(); + + } }