mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			85 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			85 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Swift
		
	
| 
											6 years ago
										 | // | ||
|  | //  Copyright (c) 2020 Open Whisper Systems. All rights reserved. | ||
|  | // | ||
|  | 
 | ||
|  | import Foundation | ||
| 
											5 years ago
										 | import SignalUtilitiesKit | ||
| 
											6 years ago
										 | 
 | ||
| 
											6 years ago
										 | final class NotificationServiceExtensionContext : NSObject, AppContext { | ||
|  |     let appLaunchTime = Date() | ||
| 
											6 years ago
										 |     let isMainApp = false | ||
|  |     let isMainAppAndActive = false | ||
|  | 
 | ||
| 
											6 years ago
										 |     var openSystemSettingsAction: UIAlertAction? | ||
| 
											5 years ago
										 |     var wasWokenUpByPushNotification = true | ||
| 
											6 years ago
										 | 
 | ||
|  |     var shouldProcessIncomingMessages: Bool { true } | ||
|  | 
 | ||
|  |     lazy var buildTime: Date = { | ||
|  |         guard let buildTimestamp = Bundle.main.object(forInfoDictionaryKey: "BuildTimestamp") as? TimeInterval, buildTimestamp > 0 else { | ||
| 
											5 years ago
										 |             SNLog("No build timestamp; assuming app never expires.") | ||
| 
											6 years ago
										 |             return .distantFuture | ||
|  |         } | ||
|  |         return .init(timeIntervalSince1970: buildTimestamp) | ||
|  |     }() | ||
|  | 
 | ||
| 
											6 years ago
										 |     override init() { super.init() } | ||
|  | 
 | ||
|  |     func canPresentNotifications() -> Bool { true } | ||
|  |     func isAppForegroundAndActive() -> Bool { false } | ||
|  |     func isInBackground() -> Bool { true } | ||
|  |     func mainApplicationStateOnLaunch() -> UIApplication.State { .inactive } | ||
|  | 
 | ||
|  |     func appDatabaseBaseDirectoryPath() -> String { | ||
|  |         return appSharedDataDirectoryPath() | ||
| 
											6 years ago
										 |     } | ||
|  | 
 | ||
|  |     func appDocumentDirectoryPath() -> String { | ||
|  |         guard let documentDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last else { | ||
| 
											6 years ago
										 |             preconditionFailure("Couldn't get document directory.") | ||
| 
											6 years ago
										 |         } | ||
|  |         return documentDirectoryURL.path | ||
|  |     } | ||
|  | 
 | ||
|  |     func appSharedDataDirectoryPath() -> String { | ||
|  |         guard let groupContainerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: SignalApplicationGroup) else { | ||
| 
											6 years ago
										 |             preconditionFailure("Couldn't get shared data directory.") | ||
| 
											6 years ago
										 |         } | ||
|  |         return groupContainerURL.path | ||
|  |     } | ||
|  | 
 | ||
|  |     func appUserDefaults() -> UserDefaults { | ||
|  |         guard let userDefaults = UserDefaults(suiteName: SignalApplicationGroup) else { | ||
| 
											6 years ago
										 |             preconditionFailure("Couldn't set up shared user defaults.") | ||
| 
											6 years ago
										 |         } | ||
|  |         return userDefaults | ||
|  |     } | ||
|  | 
 | ||
| 
											6 years ago
										 |     func keychainStorage() -> SSKKeychainStorage { | ||
|  |         return SSKDefaultKeychainStorage.shared | ||
|  |     } | ||
| 
											6 years ago
										 | 
 | ||
| 
											6 years ago
										 |     // MARK: - Currently Unused | ||
|  |      | ||
|  |     let frame = CGRect.zero | ||
|  |     let interfaceOrientation = UIInterfaceOrientation.unknown | ||
| 
											6 years ago
										 |     let isRTL = false | ||
|  |     let isRunningTests = false | ||
| 
											6 years ago
										 |     let reportedApplicationState = UIApplication.State.background | ||
|  |     let statusBarHeight = CGFloat.zero | ||
| 
											6 years ago
										 | 
 | ||
|  |     var mainWindow: UIWindow? | ||
|  | 
 | ||
|  |     func beginBackgroundTask(expirationHandler: @escaping BackgroundTaskExpirationHandler) -> UIBackgroundTaskIdentifier { .invalid } | ||
| 
											6 years ago
										 |     func beginBackgroundTask(expirationHandler: @escaping BackgroundTaskExpirationHandler) -> UInt { 0 } | ||
|  |     func endBackgroundTask(_ backgroundTaskIdentifier: UIBackgroundTaskIdentifier) { } | ||
|  |     func endBackgroundTask(_ backgroundTaskIdentifier: UInt) { } | ||
|  |     func ensureSleepBlocking(_ shouldBeBlocking: Bool, blockingObjects: [Any]) { } | ||
|  |     func ensureSleepBlocking(_ shouldBeBlocking: Bool, blockingObjectsDescription: String) { } | ||
| 
											6 years ago
										 |     func frontmostViewController() -> UIViewController? { nil } | ||
| 
											6 years ago
										 |     func runNowOr(whenMainAppIsActive block: @escaping AppActiveBlock) { } | ||
|  |     func setMainAppBadgeNumber(_ value: Int) { } | ||
|  |     func setNetworkActivityIndicatorVisible(_ value: Bool) { } | ||
|  |     func setStatusBarHidden(_ isHidden: Bool, animated isAnimated: Bool) { } | ||
| 
											6 years ago
										 | } |