Ensure we re-upload push tokens after re-registering.

// FREEBIE
This commit is contained in:
Michael Kirk 2017-11-07 14:28:08 -05:00
parent 2c5389d03f
commit c0bcc40a6f
4 changed files with 25 additions and 1 deletions

View File

@ -76,7 +76,9 @@ class AccountManager: NSObject {
private func syncPushTokens() -> Promise<Void> {
Logger.info("\(self.TAG) in \(#function)")
return SyncPushTokensJob.run(accountManager: self, preferences: self.preferences)
let job = SyncPushTokensJob(accountManager: self, preferences: self.preferences)
job.uploadOnlyIfStale = false
return job.run()
}
private func completeRegistration() {

View File

@ -91,6 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
{
DDLogInfo(@"%@ re-registering.", self.tag);
[[TSAccountManager sharedInstance] resetForRegistration];
[[Environment getCurrent].preferences unsetRecordedAPNSTokens];
RegistrationViewController *viewController = [RegistrationViewController new];
OWSNavigationController *navigationController =

View File

@ -79,6 +79,8 @@ extern NSString *const OWSPreferencesKeyEnableDebugLog;
- (void)setVoipToken:(NSString *)value;
- (nullable NSString *)getVoipToken;
- (void)unsetRecordedAPNSTokens;
@end
NS_ASSUME_NONNULL_END

View File

@ -267,6 +267,25 @@ NSString *const OWSPreferencesKeyIOSUpgradeNagVersion = @"iOSUpgradeNagVersion";
return [self tryGetValueForKey:OWSPreferencesKeyLastRecordedVoipToken];
}
- (void)unsetRecordedAPNSTokens
{
DDLogWarn(@"%@ Forgetting recorded APNS tokens", self.tag);
[self setValue:nil forKey:OWSPreferencesKeyLastRecordedPushToken];
[self setValue:nil forKey:OWSPreferencesKeyLastRecordedVoipToken];
}
#pragma mark - Logging
+ (NSString *)tag
{
return [NSString stringWithFormat:@"[%@]", self.class];
}
- (NSString *)tag
{
return self.class.tag;
}
@end
NS_ASSUME_NONNULL_END