|
|
@ -11,7 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@interface ShareAppExtensionContext ()
|
|
|
|
@interface ShareAppExtensionContext ()
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) UIViewController *rootViewController;
|
|
|
|
@property (nonatomic) UIViewController *rootViewController;
|
|
|
|
@property (atomic) BOOL isSAEInBackground;
|
|
|
|
|
|
|
|
|
|
|
|
@property (atomic) UIApplicationState reportedApplicationState;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
@ -33,6 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
_rootViewController = rootViewController;
|
|
|
|
_rootViewController = rootViewController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.reportedApplicationState = UIApplicationStateInactive;
|
|
|
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector:@selector(extensionHostDidBecomeActive:)
|
|
|
|
selector:@selector(extensionHostDidBecomeActive:)
|
|
|
|
name:NSExtensionHostDidBecomeActiveNotification
|
|
|
|
name:NSExtensionHostDidBecomeActiveNotification
|
|
|
@ -66,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
|
|
|
|
|
|
|
|
self.isSAEInBackground = NO;
|
|
|
|
self.reportedApplicationState = UIApplicationStateActive;
|
|
|
|
|
|
|
|
|
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationDidBecomeActiveNotification object:nil];
|
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationDidBecomeActiveNotification object:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -75,6 +78,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
OWSAssertIsOnMainThread();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.reportedApplicationState = UIApplicationStateInactive;
|
|
|
|
|
|
|
|
|
|
|
|
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
[DDLog flushLog];
|
|
|
|
[DDLog flushLog];
|
|
|
|
|
|
|
|
|
|
|
@ -88,7 +93,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
[DDLog flushLog];
|
|
|
|
[DDLog flushLog];
|
|
|
|
|
|
|
|
|
|
|
|
self.isSAEInBackground = YES;
|
|
|
|
self.reportedApplicationState = UIApplicationStateBackground;
|
|
|
|
|
|
|
|
|
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationDidEnterBackgroundNotification object:nil];
|
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationDidEnterBackgroundNotification object:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -99,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
DDLogInfo(@"%@ %s", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
|
|
|
|
|
|
|
|
self.isSAEInBackground = NO;
|
|
|
|
self.reportedApplicationState = UIApplicationStateInactive;
|
|
|
|
|
|
|
|
|
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationWillEnterForegroundNotification object:nil];
|
|
|
|
[NSNotificationCenter.defaultCenter postNotificationName:OWSApplicationWillEnterForegroundNotification object:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -143,13 +148,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)isInBackground
|
|
|
|
- (BOOL)isInBackground
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return self.isSAEInBackground;
|
|
|
|
return self.reportedApplicationState == UIApplicationStateBackground;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (UIApplicationState)mainApplicationState
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OWSFail(@"%@ called %s.", self.logTag, __PRETTY_FUNCTION__);
|
|
|
|
|
|
|
|
return UIApplicationStateBackground;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
|
|
|
|
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
|
|
|
|