session-ios/SignalServiceKit/src/Util/AppContext.h

41 lines
1.1 KiB
C
Raw Normal View History

2017-11-29 17:01:30 +01:00
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
2017-11-30 16:10:30 +01:00
NS_ASSUME_NONNULL_BEGIN
2017-11-29 17:01:30 +01:00
typedef void (^BackgroundTaskExpirationHandler)(void);
@class OWSDatabaseMigration;
2017-11-29 17:01:30 +01:00
@protocol AppContext <NSObject>
- (BOOL)isMainApp;
- (BOOL)isMainAppAndActive;
// Should only be called if isMainApp is YES.
//
// In general, isMainAppAndActive will probably yield more readable code.
- (UIApplicationState)mainApplicationState;
// Should start a background task if isMainApp is YES.
// Should just return UIBackgroundTaskInvalid if isMainApp is NO.
2017-11-29 17:01:30 +01:00
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
(BackgroundTaskExpirationHandler)expirationHandler;
// Should be a NOOP if isMainApp is NO.
- (void)endBackgroundTask:(UIBackgroundTaskIdentifier)backgroundTaskIdentifier;
// Should only be called if isMainApp is YES.
- (void)setMainAppBadgeNumber:(NSInteger)value;
2017-11-29 17:01:30 +01:00
- (BOOL)isRTL;
- (NSArray<OWSDatabaseMigration *> *)allMigrations;
2017-11-29 17:01:30 +01:00
@end
id<AppContext> CurrentAppContext(void);
2017-11-29 17:01:30 +01:00
void SetCurrentAppContext(id<AppContext> appContext);
2017-11-30 16:10:30 +01:00
NS_ASSUME_NONNULL_END