From eca1648054f589d4be5cb730fcff678ff4a63fd0 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Sat, 3 Mar 2018 09:04:15 -0500 Subject: [PATCH] Don't "show" upgrade splash when receiving a voip notification Wait until app is in the foreground to show upgrade splashes // FREEBIE --- .../src/ViewControllers/HomeViewController.m | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Signal/src/ViewControllers/HomeViewController.m b/Signal/src/ViewControllers/HomeViewController.m index 0943158d2..3309da4ac 100644 --- a/Signal/src/ViewControllers/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeViewController.m @@ -47,7 +47,7 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; @property (nonatomic) UISegmentedControl *segmentedControl; @property (nonatomic) id previewingContext; @property (nonatomic) NSSet *blockedPhoneNumberSet; -@property (nonatomic) BOOL viewHasEverAppeared; +@property (nonatomic) BOOL hasShownAnyUnseenUpgradeExperiences; @property (nonatomic) BOOL isViewVisible; @property (nonatomic) BOOL isAppInBackground; @@ -510,15 +510,18 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState }; }); }]; } -} - -- (void)viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; - - if (!self.viewHasEverAppeared) { - self.viewHasEverAppeared = YES; - [self displayAnyUnseenUpgradeExperience]; + + // We want to show the user the upgrade experience as soon as the app is visible to them. + // It cannot go in viewDidAppear, which is called while the app is in the background if + // we were launched from a voip notification. + if (!self.hasShownAnyUnseenUpgradeExperiences) { + dispatch_async(dispatch_get_main_queue(), ^{ + if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateForeground) { + return; + } + [self displayAnyUnseenUpgradeExperience]; + self.hasShownAnyUnseenUpgradeExperiences = YES; + }); } }