session-ios/SignalServiceKit/src/Util/AppContext.m
2018-01-10 12:18:29 -05:00

35 lines
1 KiB
Objective-C
Executable file

//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "AppContext.h"
NS_ASSUME_NONNULL_BEGIN
NSString *const OWSApplicationDidEnterBackgroundNotification = @"OWSApplicationDidEnterBackgroundNotification";
NSString *const OWSApplicationWillEnterForegroundNotification = @"OWSApplicationWillEnterForegroundNotification";
NSString *const OWSApplicationWillResignActiveNotification = @"OWSApplicationWillResignActiveNotification";
NSString *const OWSApplicationDidBecomeActiveNotification = @"OWSApplicationDidBecomeActiveNotification";
static id<AppContext> currentAppContext = nil;
id<AppContext> CurrentAppContext(void)
{
OWSCAssert(currentAppContext);
return currentAppContext;
}
void SetCurrentAppContext(id<AppContext> appContext)
{
// The main app context should only be set once.
//
// App extensions may be opened multiple times in the same process,
// so statics will persist.
OWSCAssert(!currentAppContext || !currentAppContext.isMainApp);
currentAppContext = appContext;
}
NS_ASSUME_NONNULL_END