From a284f3deb6a5044b2fc0644709953a8492fd70ca Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 6 May 2019 10:30:24 +1000 Subject: [PATCH] Don't ask for notifications --- Signal/src/AppDelegate.m | 18 ++++++---- Signal/src/Models/AccountManager.swift | 33 +++++++++++-------- .../AdvancedSettingsTableViewController.m | 23 +++++++------ 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index b1ec60158..72b5650f5 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -719,9 +719,12 @@ static NSTimeInterval launchStartedAt; // usually sufficient, but e.g. on iOS11, users who have disabled "Allow Notifications" and disabled // "Background App Refresh" will not be able to obtain an APN token. Enabling those settings does not // restart the app, so we check every activation for users who haven't yet registered. - __unused AnyPromise *promise = - [OWSSyncPushTokensJob runWithAccountManager:AppEnvironment.shared.accountManager - preferences:Environment.shared.preferences]; + // Loki: Original code + // ======== +// __unused AnyPromise *promise = +// [OWSSyncPushTokensJob runWithAccountManager:AppEnvironment.shared.accountManager +// preferences:Environment.shared.preferences]; + // ======== } if ([OWS2FAManager sharedManager].isDueForReminder) { @@ -1218,9 +1221,12 @@ static NSTimeInterval launchStartedAt; [[AppEnvironment.shared.messageFetcherJob run] retainUntilComplete]; // This should happen at any launch, background or foreground. - __unused AnyPromise *pushTokenpromise = - [OWSSyncPushTokensJob runWithAccountManager:AppEnvironment.shared.accountManager - preferences:Environment.shared.preferences]; + // Loki: Original code + // ======== +// __unused AnyPromise *pushTokenpromise = +// [OWSSyncPushTokensJob runWithAccountManager:AppEnvironment.shared.accountManager +// preferences:Environment.shared.preferences]; + // ======== } [DeviceSleepManager.sharedInstance removeBlockWithBlockObject:self]; diff --git a/Signal/src/Models/AccountManager.swift b/Signal/src/Models/AccountManager.swift index bb825b7c3..0aad4f790 100644 --- a/Signal/src/Models/AccountManager.swift +++ b/Signal/src/Models/AccountManager.swift @@ -59,20 +59,25 @@ public class AccountManager: NSObject { Logger.debug("registering with signal server") let registrationPromise: Promise = firstly { return self.registerForTextSecure(verificationCode: verificationCode, pin: pin) - }.then { _ -> Promise in - return self.syncPushTokens().recover { (error) -> Promise in - switch error { - case PushRegistrationError.pushNotSupported(let description): - // This can happen with: - // - simulators, none of which support receiving push notifications - // - on iOS11 devices which have disabled "Allow Notifications" and disabled "Enable Background Refresh" in the system settings. - Logger.info("Recovered push registration error. Registering for manual message fetcher because push not supported: \(description)") - return self.enableManualMessageFetching() - default: - throw error - } - } - }.done { (_) -> Void in + } + // Loki: Original code + // ======== +// .then { _ -> Promise in +// return self.syncPushTokens().recover { (error) -> Promise in +// switch error { +// case PushRegistrationError.pushNotSupported(let description): +// // This can happen with: +// // - simulators, none of which support receiving push notifications +// // - on iOS11 devices which have disabled "Allow Notifications" and disabled "Enable Background Refresh" in the system settings. +// Logger.info("Recovered push registration error. Registering for manual message fetcher because push not supported: \(description)") +// return self.enableManualMessageFetching() +// default: +// throw error +// } +// } +// } + // ======== + .done { (_) -> Void in self.completeRegistration() } diff --git a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m index 251ebab6d..c35bf1366 100644 --- a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m @@ -113,16 +113,19 @@ NS_ASSUME_NONNULL_BEGIN [contents addSection:loggingSection]; - OWSTableSection *pushNotificationsSection = [OWSTableSection new]; - pushNotificationsSection.headerTitle - = NSLocalizedString(@"PUSH_REGISTER_TITLE", @"Used in table section header and alert view title contexts"); - [pushNotificationsSection addItem:[OWSTableItem actionItemWithText:NSLocalizedString(@"REREGISTER_FOR_PUSH", nil) - accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( - self, @"reregister_push_notifications") - actionBlock:^{ - [weakSelf syncPushTokens]; - }]]; - [contents addSection:pushNotificationsSection]; + // Loki: Original code + // ======== +// OWSTableSection *pushNotificationsSection = [OWSTableSection new]; +// pushNotificationsSection.headerTitle +// = NSLocalizedString(@"PUSH_REGISTER_TITLE", @"Used in table section header and alert view title contexts"); +// [pushNotificationsSection addItem:[OWSTableItem actionItemWithText:NSLocalizedString(@"REREGISTER_FOR_PUSH", nil) +// accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( +// self, @"reregister_push_notifications") +// actionBlock:^{ +// [weakSelf syncPushTokens]; +// }]]; +// [contents addSection:pushNotificationsSection]; + // ======== // Censorship circumvention has certain disadvantages so it should only be // used if necessary. Therefore: