Skip to content

Commit

Permalink
various fixes for the odd "no connection" issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pliablepixels committed Feb 11, 2017
1 parent 9cf314c commit 85e4e53
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 142 deletions.
7 changes: 4 additions & 3 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
Pliable Pixels
</author>
<content src="index.html" />
<access origin="*" subdomains="true" />
<access allows-arbitrary-loads-in-media="true" allows-arbitrary-loads-in-web-content="true" allows-local-networking="true" origin="*" subdomains="true" />
<access launch-external="yes" origin="mailto:*" />
<allow-navigation href="*" />
<allow-intent href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="iosPersistentFileLocation" value="Library" />
<preference name="AllowInlineMediaPlayback" value="true" />
Expand Down Expand Up @@ -97,6 +98,6 @@
<variable name="ANDROID_HOST" value=" " />
<variable name="ANDROID_PATHPREFIX" value="/" />
</plugin>
<engine name="ios" spec="~4.1.1" />
<engine name="android" spec="~5.1.1" />
<engine name="ios" spec="~4.3.1" />
</widget>
38 changes: 19 additions & 19 deletions hooks/before_prepare/01_pp_hacks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "--------------------------------------------------"
Expand All @@ -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



Expand Down
124 changes: 5 additions & 119 deletions www/external/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,133 +28,19 @@ Licensed to the Apache Software Foundation (ASF) under one
#import "AppDelegate.h"
#import "MainViewController.h"

#import <Cordova/CDVPlugin.h>

@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 <content src='foo.html' /> 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
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<meta http-equiv="Content-Security-Policy" content="img-src * blob: android-webview-video-poster: cdvphotolibrary: 'self' data:; default-src * blob: 'self' gap: wss: ws: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';">
<meta http-equiv="Content-Security-Policy" content="img-src * blob: android-webview-video-poster: cdvphotolibrary: 'self' data:; default-src * blob: 'self' gap: wss: ws: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';connect-src * http: https: ws: wss:;">
<title></title>
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="css/animate.min.css">
Expand Down
3 changes: 3 additions & 0 deletions www/js/LoginCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ angular.module('zmApp', [
.factory('timeoutHttpIntercept', ['$rootScope', '$q', 'zm', '$injector', function($rootScope, $q, zm, $injector)
{
$rootScope.zmCookie = "";
//console.log ("HHHHHHHHHHHHHH**************************");

return {

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -1821,6 +1824,8 @@ angular.module('zmApp', [
NVRDataModel.log("Setting up POST LOGIN timer");
zmAutoLogin.start();
setupPauseAndResume();


}

}
Expand Down

0 comments on commit 85e4e53

Please sign in to comment.