Merge branch 'charlesmchen/iOS8Nag'

pull/1/head
Matthew Chen 7 years ago
commit e48542e1db

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

@ -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" #import "NewContactThreadViewController.h"
@ -278,35 +278,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
[super viewDidAppear:animated]; [super viewDidAppear:animated];
[self showIOSUpgradeNagIfNecessary]; [OWSAlerts 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.")];
}
} }
#pragma mark - Table Contents #pragma mark - Table Contents

@ -1789,7 +1789,7 @@
"UPGRADE_EXPERIENCE_VIDEO_TITLE" = "Hello Secure Video Calls!"; "UPGRADE_EXPERIENCE_VIDEO_TITLE" = "Hello Secure Video Calls!";
/* Message for the alert indicating that user should upgrade iOS. */ /* 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. */ /* Title for the alert indicating that user should upgrade iOS. */
"UPGRADE_IOS_ALERT_TITLE" = "Upgrade iOS"; "UPGRADE_IOS_ALERT_TITLE" = "Upgrade iOS";

@ -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 NS_ASSUME_NONNULL_BEGIN
@ -58,8 +58,8 @@ extern NSString *const OWSPreferencesKeyEnableDebugLog;
- (BOOL)hasDeclinedNoContactsView; - (BOOL)hasDeclinedNoContactsView;
- (void)setHasDeclinedNoContactsView:(BOOL)value; - (void)setHasDeclinedNoContactsView:(BOOL)value;
- (void)setIOSUpgradeNagVersion:(NSString *)value; - (void)setIOSUpgradeNagDate:(NSDate *)value;
- (nullable NSString *)iOSUpgradeNagVersion; - (nullable NSDate *)iOSUpgradeNagDate;
#pragma mark - Calling #pragma mark - Calling

@ -24,7 +24,7 @@ NSString *const OWSPreferencesKeyCallKitEnabled = @"CallKitEnabled";
NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled"; NSString *const OWSPreferencesKeyCallKitPrivacyEnabled = @"CallKitPrivacyEnabled";
NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress"; NSString *const OWSPreferencesKeyCallsHideIPAddress = @"CallsHideIPAddress";
NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView"; NSString *const OWSPreferencesKeyHasDeclinedNoContactsView = @"hasDeclinedNoContactsView";
NSString *const OWSPreferencesKeyIOSUpgradeNagVersion = @"iOSUpgradeNagVersion"; NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate";
NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5"; NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5";
NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistered"; NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistered";
@ -179,14 +179,14 @@ NSString *const OWSPreferencesKey_IsRegistered = @"OWSPreferencesKey_IsRegistere
[self setValueForKey:OWSPreferencesKeyHasDeclinedNoContactsView toValue:@(value)]; [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 #pragma mark - Calling

@ -65,4 +65,32 @@ import Foundation
return action 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 AppVersion.instance().lastAppVersion != nil 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."))
}
} }

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

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

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

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

@ -7,6 +7,12 @@
NS_ASSUME_NONNULL_BEGIN 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) @implementation NSDate (OWS)
+ (uint64_t)ows_millisecondTimeStamp + (uint64_t)ows_millisecondTimeStamp

Loading…
Cancel
Save