Commit e5986c10 authored by Eyad Hasan's avatar Eyad Hasan

Merge branch 'issue32-warningUserOfNoNetwork' into 'dev-1.2'

Issue32 warning user of no network

See merge request !37
parents b9444a1c fa7158eb
......@@ -9,9 +9,6 @@
/* Begin PBXBuildFile section */
230EC5797C17C0F859125EEE /* Pods_WhatsOpen.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 927A8466141434969CE74044 /* Pods_WhatsOpen.framework */; };
3BF943DF148D3237C16DEB97 /* Pods_WhatsOpen___AppStore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 857A9086C28DB736094E251F /* Pods_WhatsOpen___AppStore.framework */; };
7B2F14EF214705EF006FB94A /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2F14EE214705EF006FB94A /* Reachability.swift */; };
7B2F14F0214705EF006FB94A /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2F14EE214705EF006FB94A /* Reachability.swift */; };
7B2F14F1214705EF006FB94A /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B2F14EE214705EF006FB94A /* Reachability.swift */; };
7F4743271E11D1BC00E6E3D1 /* MainTableViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F4743261E11D1BC00E6E3D1 /* MainTableViewControllerTests.swift */; };
9203CB862023D51A006ACC3B /* FilterSelectionTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92B2D2FE1FF8599500349E90 /* FilterSelectionTableViewController.swift */; };
9203CB872023D51A006ACC3B /* FacilityDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92182EC31E95C38400192ABA /* FacilityDetailViewController.swift */; };
......@@ -86,7 +83,6 @@
2A5CE0045EF9683B296DF70C /* Pods-WhatsOpen.app store.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WhatsOpen.app store.xcconfig"; path = "Pods/Target Support Files/Pods-WhatsOpen/Pods-WhatsOpen.app store.xcconfig"; sourceTree = "<group>"; };
310EA38816D0F5ADA89E7E4E /* Pods-WhatsOpen - AppStore.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WhatsOpen - AppStore.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WhatsOpen - AppStore/Pods-WhatsOpen - AppStore.debug.xcconfig"; sourceTree = "<group>"; };
4CB5379771C173448AFCB711 /* Pods-WhatsOpen.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WhatsOpen.release.xcconfig"; path = "Pods/Target Support Files/Pods-WhatsOpen/Pods-WhatsOpen.release.xcconfig"; sourceTree = "<group>"; };
7B2F14EE214705EF006FB94A /* Reachability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = "<group>"; };
7F4743181E11C7D100E6E3D1 /* WhatsOpenTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WhatsOpenTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7F4743261E11D1BC00E6E3D1 /* MainTableViewControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainTableViewControllerTests.swift; sourceTree = "<group>"; };
857A9086C28DB736094E251F /* Pods_WhatsOpen___AppStore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = "Pods_WhatsOpen___AppStore.framework"; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -279,7 +275,6 @@
children = (
CD763A791DE24EF100ADFD6B /* Model.swift */,
CD3C97481DC18AB300A84434 /* DownloadController.swift */,
7B2F14EE214705EF006FB94A /* Reachability.swift */,
);
name = "Data Retrieval";
sourceTree = "<group>";
......@@ -392,7 +387,7 @@
};
CD81F5181DC0334600009FBD = {
CreatedOnToolsVersion = 8.0;
DevelopmentTeam = N5GM564QWL;
DevelopmentTeam = HQSN7HX89U;
LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
};
......@@ -660,7 +655,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7B2F14F0214705EF006FB94A /* Reachability.swift in Sources */,
7F4743271E11D1BC00E6E3D1 /* MainTableViewControllerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -683,7 +677,6 @@
9203CB922023D51A006ACC3B /* FacilityCollectionViewCell.swift in Sources */,
9203CB932023D51A006ACC3B /* SettingTableViewCell.swift in Sources */,
9203CB942023D51A006ACC3B /* Filters.swift in Sources */,
7B2F14F1214705EF006FB94A /* Reachability.swift in Sources */,
9203CB952023D51A006ACC3B /* FiltersTableViewController.swift in Sources */,
9203CB962023D51A006ACC3B /* PullingViewController.swift in Sources */,
9203CB972023D51A006ACC3B /* Utilities.swift in Sources */,
......@@ -714,7 +707,6 @@
924840F81EA915F200DBFF4E /* FacilityCollectionViewCell.swift in Sources */,
9265F3A11F2969E500A54A21 /* SettingTableViewCell.swift in Sources */,
9270A4DD1EC0010300DFBDA3 /* Filters.swift in Sources */,
7B2F14EF214705EF006FB94A /* Reachability.swift in Sources */,
927C80DC1EB18B89009079AD /* FiltersTableViewController.swift in Sources */,
92B89E302009444E00928284 /* PullingViewController.swift in Sources */,
CD763A7E1DE253B900ADFD6B /* Utilities.swift in Sources */,
......@@ -944,7 +936,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = K5MMVK2UFR;
DEVELOPMENT_TEAM = HQSN7HX89U;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......@@ -954,7 +946,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -D APPSTORE";
PRIMARYICON = appicon;
PRODUCT_BUNDLE_IDENTIFIER = space.srct.whatsopen;
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
......@@ -1095,11 +1087,12 @@
baseConfigurationReference = F92A491DB8E91DDE3DCB7ED2 /* Pods-WhatsOpen.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = "appicon-dev";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = N5GM564QWL;
DEVELOPMENT_TEAM = HQSN7HX89U;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......@@ -1108,7 +1101,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRIMARYICON = "appicon-dev";
PRODUCT_BUNDLE_IDENTIFIER = space.srct.whatsopen;
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
......@@ -1123,11 +1116,12 @@
baseConfigurationReference = 4CB5379771C173448AFCB711 /* Pods-WhatsOpen.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = "appicon-dev";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = N5GM564QWL;
DEVELOPMENT_TEAM = HQSN7HX89U;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
......@@ -1136,7 +1130,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRIMARYICON = "appicon-dev";
PRODUCT_BUNDLE_IDENTIFIER = space.srct.whatsopen;
PRODUCT_BUNDLE_IDENTIFIER = io.srct.whatsopen;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
......
......@@ -31,6 +31,7 @@ class DownloadController: NSObject {
let httpResponse = response as! HTTPURLResponse
let statusCode = httpResponse.statusCode
if (statusCode == 200) {
networkCheck.network = true
if let dataN = data {
if let json = try? JSONSerialization.jsonObject(with: dataN, options: []) as? [[String: Any]] {
// Map function to iterate through each JSON tree
......
......@@ -20,6 +20,11 @@ enum Day: Int {
// Add functions here later if we need them
}
struct networkCheck {
static var network:Bool = false
}
class Facility: Object, MapContext, Mappable {
@objc dynamic var slug = ""
@objc dynamic var facilityName = ""
......
......@@ -14,16 +14,17 @@ public class Reachability {
var status:Bool = false
let url = NSURL(string: "https://google.com")
let request = NSMutableURLRequest(url: url! as URL)
let url = URL(string: "https://api.srct.gmu.edu/whatsopen/v2/facilities/?format=json")
var request = URLRequest(url: url! as URL)
request.httpMethod = "HEAD"
request.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalAndRemoteCacheData
request.cachePolicy = URLRequest.CachePolicy.reloadIgnoringLocalAndRemoteCacheData
request.timeoutInterval = 10.0
var response:URLResponse?
do {
let _ = try NSURLConnection.sendSynchronousRequest(request as URLRequest, returning: &response) as NSData?
//let _ = try NSURLConnection.sendSynchronousRequest(request as URLRequest, returning: &response) as NSData?
let _ = try URLSession.dataTaskWithRequest(request as URLRequest, completionHandler: &response)
}
catch let error as NSError {
print(error.localizedDescription)
......
......@@ -358,10 +358,9 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let alertFilers = defaults.dictionary(forKey: "alerts") as! [String: Bool]?
// Probably a better way to do the check for network results, but it really doesn't matter so this will do for now.
var noNetwork = Reachability.isConnectedToNetwork()
let noNetworkAlert = Alert()
noNetworkAlert.noNetwork()
if !noNetwork {
if networkCheck.network == false {
shown.append(noNetworkAlert)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment