diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index af10bde48..207d8739c 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -24,7 +24,6 @@ #import "VersionMigrations.h" #import "ViewControllerUtils.h" #import -#import #import #import #import @@ -151,13 +150,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager] accountManager:[Environment getCurrent].accountManager - preferences:[Environment preferences]] - .then(^{ - DDLogDebug(@"%@ Successfully ran syncPushTokensJob.", self.tag); - }) - .catch(^(NSError *_Nonnull error) { - DDLogError(@"%@ Failed to run syncPushTokensJob with error: %@", self.tag, error); - }); + preferences:[Environment preferences]]; // Clean up any messages that expired since last launch. [[[OWSDisappearingMessagesJob alloc] initWithStorageManager:[TSStorageManager sharedManager]] run]; diff --git a/Signal/src/Models/SyncPushTokensJob.swift b/Signal/src/Models/SyncPushTokensJob.swift index a96f6ece5..ea16d292f 100644 --- a/Signal/src/Models/SyncPushTokensJob.swift +++ b/Signal/src/Models/SyncPushTokensJob.swift @@ -18,16 +18,12 @@ class SyncPushTokensJob: NSObject { self.preferences = preferences } - @objc class func run(pushManager: PushManager, accountManager: AccountManager, preferences: PropertyListPreferences) -> AnyPromise { + @objc class func run(pushManager: PushManager, accountManager: AccountManager, preferences: PropertyListPreferences) { let job = self.init(pushManager: pushManager, accountManager: accountManager, preferences: preferences) - return AnyPromise(job.run()) + job.run() } - @objc func run() -> AnyPromise { - return AnyPromise(run()) - } - - func run() -> Promise { + func run() { Logger.debug("\(TAG) Starting.") // Required to potentially prompt user for notifications settings @@ -43,11 +39,14 @@ class SyncPushTokensJob: NSObject { return self.accountManager.updatePushTokens(pushToken:pushToken, voipToken:voipToken).then { return self.recordNewPushTokens(pushToken:pushToken, voipToken:voipToken) + } + }.then { + Logger.debug("\(self.TAG) Successfully ran syncPushTokensJob.") + }.catch { error in + Logger.error("\(self.TAG) Failed to run syncPushTokensJob with error: \(error).") } - } - runPromise.retainUntilComplete() - return runPromise + runPromise.retainUntilComplete() } private func requestPushTokens() -> Promise<(pushToken: String, voipToken: String)> { diff --git a/Signal/src/ViewControllers/AdvancedSettingsTableViewController.m b/Signal/src/ViewControllers/AdvancedSettingsTableViewController.m index a69ecb3bc..7c6772d34 100644 --- a/Signal/src/ViewControllers/AdvancedSettingsTableViewController.m +++ b/Signal/src/ViewControllers/AdvancedSettingsTableViewController.m @@ -10,7 +10,6 @@ #import "Signal-Swift.h" #import "TSAccountManager.h" #import "Pastelog.h" -#import NS_ASSUME_NONNULL_BEGIN @@ -130,22 +129,9 @@ typedef NS_ENUM(NSInteger, AdvancedSettingsTableViewControllerSection) { [DDLog flushLog]; [Pastelog submitLogs]; } else if ([tableView cellForRowAtIndexPath:indexPath] == self.registerPushCell) { - OWSSyncPushTokensJob *syncJob = - [[OWSSyncPushTokensJob alloc] initWithPushManager:[PushManager sharedManager] - accountManager:[Environment getCurrent].accountManager - preferences:[Environment preferences]]; - [syncJob run] - .then(^{ - DDLogDebug(@"%@ Successfully ran syncPushTokensJob.", self.tag); - [OWSAlerts showAlertWithTitle:NSLocalizedString(@"PUSH_REGISTER_SUCCESS", - @"Title of alert shown when push tokens sync job succeeds.")]; - }) - .catch(^(NSError *error) { - DDLogError(@"%@ Failed to run syncPushTokensJob with error: %@", self.tag, error); - [OWSAlerts showAlertWithTitle:NSLocalizedString(@"REGISTRATION_BODY", - @"Title of alert shown when push tokens sync job fails.")]; - }); - + [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager] + accountManager:[Environment getCurrent].accountManager + preferences:[Environment preferences]]; } else { DDLogDebug(@"%@ Ignoring cell selection at indexPath: %@", self.tag, indexPath); } diff --git a/Signal/src/ViewControllers/SignalsViewController.m b/Signal/src/ViewControllers/SignalsViewController.m index 953fce5f0..150e93e29 100644 --- a/Signal/src/ViewControllers/SignalsViewController.m +++ b/Signal/src/ViewControllers/SignalsViewController.m @@ -18,7 +18,6 @@ #import "TSStorageManager.h" #import "UIUtil.h" #import "VersionMigrations.h" -#import #import #import #import @@ -339,13 +338,7 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS { [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager] accountManager:self.accountManager - preferences:[Environment preferences]] - .then(^{ - DDLogDebug(@"%@ Successfully ran syncPushTokensJob.", self.tag); - }) - .catch(^(NSError *_Nonnull error) { - DDLogError(@"%@ Failed to run syncPushTokensJob with error: %@", self.tag, error); - }); + preferences:[Environment preferences]]; } - (void)tableViewSetUp {