Aggressively nag iOS 8 users to upgrade iOS.

This commit is contained in:
Matthew Chen 2018-02-13 15:00:25 -05:00
parent 132bf81c08
commit 4b62faf2f8
11 changed files with 57 additions and 52 deletions

View File

@ -560,6 +560,8 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
}];
} else if (!self.hasBeenPresented && [ProfileViewController shouldDisplayProfileViewOnLaunch]) {
[ProfileViewController presentForUpgradeOrNag:self];
} else {
[OWSAlerts showIOSUpgradeNagIfNecessary];
}
self.hasBeenPresented = YES;

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "NewContactThreadViewController.h"
@ -278,35 +278,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[super viewDidAppear:animated];
[self showIOSUpgradeNagIfNecessary];
}
- (void)showIOSUpgradeNagIfNecessary
{
// Only show the nag to iOS 8 users.
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) {
return;
}
// Don't show the nag to users who have just launched
// the app for the first time.
if (![AppVersion instance].lastAppVersion) {
return;
}
// Only show the nag once per update of the app.
NSString *currentAppVersion = [AppVersion instance].currentAppVersion;
OWSAssert(currentAppVersion.length > 0);
NSString *lastNagAppVersion = [Environment.preferences iOSUpgradeNagVersion];
if (lastNagAppVersion && ![lastNagAppVersion isEqualToString:currentAppVersion]) {
[Environment.preferences setIOSUpgradeNagVersion:currentAppVersion];
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"UPGRADE_IOS_ALERT_TITLE",
@"Title for the alert indicating that user should upgrade iOS.")
message:NSLocalizedString(@"UPGRADE_IOS_ALERT_MESSAGE",
@"Message for the alert indicating that user should upgrade iOS.")];
}
[OWSAlerts showIOSUpgradeNagIfNecessary];
}
#pragma mark - Table Contents

View File

@ -1789,7 +1789,7 @@
"UPGRADE_EXPERIENCE_VIDEO_TITLE" = "Hello Secure Video Calls!";
/* Message for the alert indicating that user should upgrade iOS. */
"UPGRADE_IOS_ALERT_MESSAGE" = "Signal will soon require iOS 9 or later. Please upgrade in Settings app >> General >> Software Update.";
"UPGRADE_IOS_ALERT_MESSAGE" = "Signal requires iOS 9 or later. Please upgrade iOS in Settings app >> General >> Software Update.";
/* Title for the alert indicating that user should upgrade iOS. */
"UPGRADE_IOS_ALERT_TITLE" = "Upgrade iOS";

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@ -58,8 +58,8 @@ extern NSString *const OWSPreferencesKeyEnableDebugLog;
- (BOOL)hasDeclinedNoContactsView;
- (void)setHasDeclinedNoContactsView:(BOOL)value;
- (void)setIOSUpgradeNagVersion:(NSString *)value;
- (nullable NSString *)iOSUpgradeNagVersion;
- (void)setIOSUpgradeNagDate:(NSDate *)value;
- (nullable NSDate *)iOSUpgradeNagDate;
#pragma mark - Calling

View File

@ -24,7 +24,7 @@ NSString *const OWSPreferencesKeyCallKitEnabled = @"CallKitEnabled";
NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled";
NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress";
NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView";
NSString *const OWSPreferencesKeyIOSUpgradeNagVersion = @"iOSUpgradeNagVersion";
NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistered";
@ -179,14 +179,14 @@ NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistere
[self setValueForKey:OWSPreferencesKeyHasDeclinedNoContactsView toValue:@(value)];
}
- (void)setIOSUpgradeNagVersion:(NSString *)value
- (void)setIOSUpgradeNagDate:(NSDate *)value
{
[self setValueForKey:OWSPreferencesKeyIOSUpgradeNagVersion toValue:value];
[self setValueForKey:OWSPreferencesKeyIOSUpgradeNagDate toValue:value];
}
- (nullable NSString *)iOSUpgradeNagVersion
- (nullable NSDate *)iOSUpgradeNagDate
{
return [self tryGetValueForKey:OWSPreferencesKeyIOSUpgradeNagVersion];
return [self tryGetValueForKey:OWSPreferencesKeyIOSUpgradeNagDate];
}
#pragma mark - Calling

View File

@ -65,4 +65,32 @@ import Foundation
return action
}
@objc
public class func showIOSUpgradeNagIfNecessary() {
// Only show the nag to iOS 8 users.
if #available(iOS 9.0, *) {
return
}
// Don't show the nag to users who have just launched
// the app for the first time.
guard let _ = AppVersion.instance().lastAppVersion else {
return
}
if let iOSUpgradeNagDate = Environment.preferences().iOSUpgradeNagDate() {
// Nag no more than once every three days.
let kNagFrequencySeconds = 3 * kDayInterval
guard fabs(iOSUpgradeNagDate.timeIntervalSinceNow) > kNagFrequencySeconds else {
return
}
}
Environment.preferences().setIOSUpgradeNagDate(Date())
OWSAlerts.showAlert(withTitle:NSLocalizedString("UPGRADE_IOS_ALERT_TITLE",
comment:"Title for the alert indicating that user should upgrade iOS."),
message:NSLocalizedString("UPGRADE_IOS_ALERT_MESSAGE",
comment:"Message for the alert indicating that user should upgrade iOS."))
}
}

View File

@ -15,17 +15,17 @@
// Time before deletion of signed prekeys (measured in seconds)
//
// Currently we retain signed prekeys for at least 7 days.
static const NSTimeInterval kSignedPreKeysDeletionTime = 7 * kDayInterval;
#define kSignedPreKeysDeletionTime ((NSTimeInterval)7 * kDayInterval)
// Time before rotation of signed prekeys (measured in seconds)
//
// Currently we rotate signed prekeys every 2 days (48 hours).
static const NSTimeInterval kSignedPreKeyRotationTime = 2 * kDayInterval;
#define kSignedPreKeyRotationTime ((NSTimeInterval)7 * kDayInterval)
// How often we check prekey state on app activation.
//
// Currently we check prekey state every 12 hours.
static const NSTimeInterval kPreKeyCheckFrequencySeconds = 12 * kHourInterval;
#define kPreKeyCheckFrequencySeconds ((NSTimeInterval)12 * kHourInterval)
// We generate 100 one-time prekeys at a time. We should replenish
// whenever ~2/3 of them have been consumed.
@ -42,7 +42,7 @@ static const NSUInteger kMaxPrekeyUpdateFailureCount = 5;
// before the message sending is disabled.
//
// Current value is 10 days (240 hours).
static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 * kDayInterval;
#define kSignedPreKeyUpdateFailureMaxFailureDuration ((NSTimeInterval)10 * kDayInterval)
#pragma mark -

View File

@ -6,7 +6,7 @@
NS_ASSUME_NONNULL_BEGIN
extern const uint32_t OWSDisappearingMessagesConfigurationDefaultExpirationDuration;
#define OWSDisappearingMessagesConfigurationDefaultExpirationDuration kDayInterval
@interface OWSDisappearingMessagesConfiguration : TSYapDatabaseObject

View File

@ -7,9 +7,6 @@
NS_ASSUME_NONNULL_BEGIN
// 1 day.
const uint32_t OWSDisappearingMessagesConfigurationDefaultExpirationDuration = kDayInterval;
@interface OWSDisappearingMessagesConfiguration ()
// Transient record lifecycle attributes.

View File

@ -5,11 +5,11 @@
NS_ASSUME_NONNULL_BEGIN
// These NSTimeInterval constants provide simplified durations for readability.
#define kMinuteInterval 60
#define kHourInterval (60 * kMinuteInterval)
#define kDayInterval (24 * kHourInterval)
#define kWeekInterval (7 * kDayInterval)
#define kMonthInterval (30 * kDayInterval)
extern const NSTimeInterval kMinuteInterval;
extern const NSTimeInterval kHourInterval;
extern const NSTimeInterval kDayInterval;
extern const NSTimeInterval kWeekInterval;
extern const NSTimeInterval kMonthInterval;
#define kSecondInMs 1000
#define kMinuteInMs (kSecondInMs * 60)

View File

@ -7,6 +7,12 @@
NS_ASSUME_NONNULL_BEGIN
const NSTimeInterval kMinuteInterval = 60;
const NSTimeInterval kHourInterval = 60 * kMinuteInterval;
const NSTimeInterval kDayInterval = 24 * kHourInterval;
const NSTimeInterval kWeekInterval = 7 * kDayInterval;
const NSTimeInterval kMonthInterval = 30 * kDayInterval;
@implementation NSDate (OWS)
+ (uint64_t)ows_millisecondTimeStamp