Skip to content

Commit

Permalink
[2.5.1] mostly cleanup, but also one big uncommitted change is still …
Browse files Browse the repository at this point in the history
…developing so this won't compile...
  • Loading branch information
biblicabeebli committed May 2, 2024
1 parent 02a92a3 commit 34429f2
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 48 deletions.
16 changes: 8 additions & 8 deletions Beiwe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2024.21;
CURRENT_PROJECT_VERSION = 2024.22;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6M52R5C7FT;
ENABLE_BITCODE = NO;
Expand All @@ -888,7 +888,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.5;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = harvard.lab.onnela.beiwe.ios;
PRODUCT_NAME = Beiwe2;
PROVISIONING_PROFILE = "";
Expand Down Expand Up @@ -979,7 +979,7 @@
CODE_SIGN_ENTITLEMENTS = Beiwe/Beiwe2Release2.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2024.21;
CURRENT_PROJECT_VERSION = 2024.22;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6M52R5C7FT;
ENABLE_BITCODE = NO;
Expand All @@ -988,7 +988,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.5;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = harvard.lab.onnela.beiwe.ios;
PRODUCT_NAME = Beiwe2;
PROVISIONING_PROFILE = "";
Expand Down Expand Up @@ -1146,7 +1146,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2024.21;
CURRENT_PROJECT_VERSION = 2024.22;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6M52R5C7FT;
ENABLE_BITCODE = NO;
Expand All @@ -1155,7 +1155,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.5;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = lab.onnela.beiwe.ios;
PRODUCT_NAME = Beiwe;
PROVISIONING_PROFILE = "";
Expand Down Expand Up @@ -1184,7 +1184,7 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Onnela Lab LLC (6M52R5C7FT)";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2024.21;
CURRENT_PROJECT_VERSION = 2024.22;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6M52R5C7FT;
ENABLE_BITCODE = NO;
Expand All @@ -1193,7 +1193,7 @@
INFOPLIST_PREPROCESS = NO;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.5;
MARKETING_VERSION = 2.5.1;
PRODUCT_BUNDLE_IDENTIFIER = lab.onnela.beiwe.ios;
PRODUCT_NAME = Beiwe;
PROVISIONING_PROFILE = "";
Expand Down
6 changes: 5 additions & 1 deletion Beiwe/API/ApiManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ enum ApiErrors: Error {
case fileNotFound
}

/// One(?) of the request types... no clue how this works yet, but mappables magically convert json
/// This is what we ended up using for our post requests after the promisekit purge, I thought it
/// was part of Alamofire. It isn't. It just takes the output of the request and sticks it on a
/// .body property. Complete garbage intermidiate object.
/// Fixme: kill this class, why are we even using a mappable that's insane. Call the correct
/// Mappable that you need on the body output of the api requests explicitly.
struct BodyResponse: Mappable {
var body: String?

Expand Down
75 changes: 40 additions & 35 deletions Beiwe/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
return StudyManager.sharedInstance.currentStudy
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// APPLICATION SETUP ////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// APPLICATION SETUP ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

/// The AppDelegate started function
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Expand Down Expand Up @@ -94,7 +94,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
return true
}

// this is currently literally just being tested because I don't know what it does but apple has documentation about it and the BGTasks are completely unreliable right now.
/// Target(?) for background app refresh https://developer.apple.com/documentation/uikit/uiapplication/1623031-beginbackgroundtask
// """ A handler to be called shortly before the app’s remaining background time
// reaches 0. Use this handler to clean up and mark the end of the background task.
// Failure to end the task explicitly will result in the termination of the app.
// The system calls the handler synchronously on the main thread, blocking the
// app’s suspension momentarily. """
func beginBackgroundTask(withName taskName: String?, expirationHandler handler: (() -> Void)? = nil) -> UIBackgroundTaskIdentifier {
StudyManager.sharedInstance.heartbeat("beginBackgroundTask")
return UIBackgroundTaskIdentifier(rawValue: 0)
Expand Down Expand Up @@ -231,7 +236,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
@unknown default: "unknown: '\(UIApplication.shared.backgroundRefreshStatus.rawValue)'"
}
}

// print("UIApplication.shared.backgroundTimeRemaining:", UIApplication.shared.backgroundTimeRemaining)
updateBackgroundTasksCount()

BACKGROUND_DEVICE_INFO_QUEUE.asyncAfter(deadline: .now() + 60, execute: self.deviceInfoUpdateLoop)
Expand Down Expand Up @@ -305,9 +310,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
return false
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// APPLICATION WILL X ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// APPLICATION WILL X //////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

func applicationWillEnterForeground(_ application: UIApplication) {
print("applicationWillEnterForeground")
Expand Down Expand Up @@ -369,9 +374,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
print("applicationWillResignActive")
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// APPLICATION DID X ////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// APPLICATION DID X //////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
Expand Down Expand Up @@ -414,9 +419,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
AppEventManager.sharedInstance.logAppEvent(event: "locked", msg: "Phone/keystore locked")
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// PERMISSIONS //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////// PERMISSIONS //////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

/// this function gets called when CLAuthorization status changes
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
Expand Down Expand Up @@ -446,9 +451,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// REAL NOTIFICATION CODE ///////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// REAL NOTIFICATION CODE /////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Failed to register for notifications: \(error.localizedDescription)")
Expand Down Expand Up @@ -518,7 +523,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
// return if nothing found
guard let surveyIdsString = messageInfo["survey_ids"] else {
print("no surveyIds found, checking for new surveys anyway.")
StudyManager.sharedInstance.downloadSurveys(surveyIds: [])
StudyManager.sharedInstance.checkForNewSurveys(surveyIds: [])
return
}

Expand All @@ -529,15 +534,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
// downloadSurveys calls setActiveSurveys, even if it errors/fails. We always want to download the most recent survey information.
// (old versions of the backend don't supply the sent_time key)
if let sentTimeString = messageInfo["sent_time"] as! String? {
StudyManager.sharedInstance.downloadSurveys(surveyIds: surveyIds, sentTime: isoStringToTimeInterval(timeString: sentTimeString))
StudyManager.sharedInstance.checkForNewSurveys(surveyIds: surveyIds, sentTime: isoStringToTimeInterval(timeString: sentTimeString))
} else {
StudyManager.sharedInstance.downloadSurveys(surveyIds: surveyIds)
StudyManager.sharedInstance.checkForNewSurveys(surveyIds: surveyIds)
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// MISC BEIWE STUFF /////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// MISC BEIWE STUFF ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

// converts json string to an array of strings
func jsonToSurveyIdArray(json: String) -> [String] {
Expand All @@ -554,9 +559,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
return surveyIds
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// Firebase Stuff ///////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////// Firebase Stuff ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

func firebaseLoop() {
// The app cannot register with firebase until it gets a token, which only occurs at registration time, and it needs access to the appDelegate.
Expand Down Expand Up @@ -663,9 +668,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// UI STUFF ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////// STUFF //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

func initializeUI() {
// set up colors for researchkit, set the launch screen view.
Expand Down Expand Up @@ -719,9 +724,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// CRASHLYTICS STUFF ////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// CRASHLYTICS STUFF ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

// func setupCrashLytics() {
// Fabric.with([Crashlytics.self])
Expand Down Expand Up @@ -752,9 +757,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate
// Crashlytics.sharedInstance().crash()
// }

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// SENTRY STUFF ////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// SENTRY STUFF //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

func setupSentry() {
// loads sentry key, prints an error if it doesn't work.
Expand Down
1 change: 0 additions & 1 deletion Beiwe/Controllers/AudioQuestionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ class AudioQuestionViewController: UIViewController, AVAudioRecorderDelegate, AV
do {
self.saveEncryptedAudio()
self.activeSurvey.isComplete = true
StudyManager.sharedInstance.cleanupSurvey(self.activeSurvey)
StudyManager.sharedInstance.updateActiveSurveys(true)
HUD.flash(.success, delay: 0.5)
self.cleanupAndDismiss()
Expand Down
6 changes: 3 additions & 3 deletions Beiwe/Managers/DataStorageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ class DataStorageManager {
// }
}

////////////////////////////////////////////////////// Data Storage ///////////////////////////////////////////////////////
////////////////////////////////////////////////////// Data Storage ///////////////////////////////////////////////////////
////////////////////////////////////////////////////// Data Storage ///////////////////////////////////////////////////////
///////////////////////////////////////////// Data Storage /////////////////////////////////////////
///////////////////////////////////////////// Data Storage /////////////////////////////////////////
///////////////////////////////////////////// Data Storage /////////////////////////////////////////

class DataStorage {
// participant info (to be factored out)
Expand Down

0 comments on commit 34429f2

Please sign in to comment.