mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
Only check for updates when the app becomes active and was actually in the background previously
This commit is contained in:
parent
aff8c0a9a9
commit
bc9ee21078
@ -60,7 +60,8 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
|||||||
BOOL _sendUsageData;
|
BOOL _sendUsageData;
|
||||||
|
|
||||||
BOOL _didSetupDidBecomeActiveNotifications;
|
BOOL _didSetupDidBecomeActiveNotifications;
|
||||||
|
BOOL _didEnterBackgroundState;
|
||||||
|
|
||||||
BOOL _firstStartAfterInstall;
|
BOOL _firstStartAfterInstall;
|
||||||
|
|
||||||
NSNumber *_versionID;
|
NSNumber *_versionID;
|
||||||
@ -89,6 +90,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
|||||||
|
|
||||||
- (void)didBecomeActiveActions {
|
- (void)didBecomeActiveActions {
|
||||||
if ([self isUpdateManagerDisabled]) return;
|
if ([self isUpdateManagerDisabled]) return;
|
||||||
|
if (!_didEnterBackgroundState) return;
|
||||||
|
|
||||||
[self checkExpiryDateReached];
|
[self checkExpiryDateReached];
|
||||||
if ([self expiryDateReached]) return;
|
if ([self expiryDateReached]) return;
|
||||||
@ -99,9 +101,18 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)didEnterBackgroundActions {
|
||||||
|
_didEnterBackgroundState = NO;
|
||||||
|
|
||||||
|
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
|
||||||
|
_didEnterBackgroundState = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setupDidBecomeActiveNotifications {
|
- (void)setupDidBecomeActiveNotifications {
|
||||||
if (!_didSetupDidBecomeActiveNotifications) {
|
if (!_didSetupDidBecomeActiveNotifications) {
|
||||||
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
|
||||||
|
[dnc addObserver:self selector:@selector(didEnterBackgroundActions) name:UIApplicationDidEnterBackgroundNotification object:nil];
|
||||||
[dnc addObserver:self selector:@selector(didBecomeActiveActions) name:UIApplicationDidBecomeActiveNotification object:nil];
|
[dnc addObserver:self selector:@selector(didBecomeActiveActions) name:UIApplicationDidBecomeActiveNotification object:nil];
|
||||||
[dnc addObserver:self selector:@selector(didBecomeActiveActions) name:BITHockeyNetworkDidBecomeReachableNotification object:nil];
|
[dnc addObserver:self selector:@selector(didBecomeActiveActions) name:BITHockeyNetworkDidBecomeReachableNotification object:nil];
|
||||||
_installationIdentification = [self stringValueFromKeychainForKey:kBITUpdateInstallationIdentification];
|
_installationIdentification = [self stringValueFromKeychainForKey:kBITUpdateInstallationIdentification];
|
||||||
@ -112,6 +123,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
|||||||
- (void)cleanupDidBecomeActiveNotifications {
|
- (void)cleanupDidBecomeActiveNotifications {
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:BITHockeyNetworkDidBecomeReachableNotification object:nil];
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:BITHockeyNetworkDidBecomeReachableNotification object:nil];
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user