session-ios/SessionMessagingKit/Utilities/AppReadiness.h

40 lines
1.4 KiB
C
Raw Normal View History

2020-11-11 00:58:56 +01:00
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef void (^AppReadyBlock)(void);
@interface AppReadiness : NSObject
- (instancetype)init NS_UNAVAILABLE;
// This method can be called on any thread.
+ (BOOL)isAppReady;
// This method should only be called on the main thread.
+ (void)setAppIsReady;
// If the app is ready, the block is called immediately;
// otherwise it is called when the app becomes ready.
//
// This method should only be called on the main thread.
// The block will always be called on the main thread.
//
// * The "will become ready" blocks are called before the "did become ready" blocks.
// * The "will become ready" blocks should be used for internal setup of components
// so that they are ready to interact with other components of the system.
// * The "did become ready" blocks should be used for any work that should be done
// on app launch, especially work that uses other components.
// * We should usually use "did become ready" blocks since they are safer.
+ (void)runNowOrWhenAppWillBecomeReady:(AppReadyBlock)block NS_SWIFT_NAME(runNowOrWhenAppWillBecomeReady(_:));
2021-08-05 06:15:34 +02:00
+ (void)runNowOrWhenAppDidBecomeReadySync:(AppReadyBlock)block NS_SWIFT_NAME(runNowOrWhenAppDidBecomeReadySync(_:));
2020-11-11 00:58:56 +01:00
+ (void)runNowOrWhenAppDidBecomeReady:(AppReadyBlock)block NS_SWIFT_NAME(runNowOrWhenAppDidBecomeReady(_:));
@end
NS_ASSUME_NONNULL_END