pull/160/head
nielsandriesse 6 years ago
parent 5874387dda
commit 619c3a7f84

@ -587,6 +587,8 @@ static BOOL isInternalTestVersion = NO;
return; return;
} }
[self.pushRegistrationManager didReceiveVanillaPushToken:deviceToken];
OWSLogInfo(@"Registering for push notifications with token: %@.", deviceToken); OWSLogInfo(@"Registering for push notifications with token: %@.", deviceToken);
BOOL isUsingFullAPNs = [NSUserDefaults.standardUserDefaults boolForKey:@"isUsingFullAPNs"]; BOOL isUsingFullAPNs = [NSUserDefaults.standardUserDefaults boolForKey:@"isUsingFullAPNs"];
if (isUsingFullAPNs) { if (isUsingFullAPNs) {

@ -2,6 +2,8 @@
// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
@import PromiseKit;
#import "NotificationSettingsViewController.h" #import "NotificationSettingsViewController.h"
#import "NotificationSettingsOptionsViewController.h" #import "NotificationSettingsOptionsViewController.h"
#import "OWSSoundSettingsViewController.h" #import "OWSSoundSettingsViewController.h"
@ -139,7 +141,7 @@
[NSUserDefaults.standardUserDefaults setBool:sender.on forKey:@"isUsingFullAPNs"]; [NSUserDefaults.standardUserDefaults setBool:sender.on forKey:@"isUsingFullAPNs"];
OWSSyncPushTokensJob *syncTokensJob = [[OWSSyncPushTokensJob alloc] initWithAccountManager:AppEnvironment.shared.accountManager preferences:Environment.shared.preferences]; OWSSyncPushTokensJob *syncTokensJob = [[OWSSyncPushTokensJob alloc] initWithAccountManager:AppEnvironment.shared.accountManager preferences:Environment.shared.preferences];
syncTokensJob.uploadOnlyIfStale = NO; syncTokensJob.uploadOnlyIfStale = NO;
__unused AnyPromise *promise = [syncTokensJob run]; [[syncTokensJob run] retainUntilComplete];
} }
@end @end

@ -63,10 +63,8 @@ public enum PushRegistrationError: Error {
throw PushRegistrationError.pushNotSupported(description: "Push not supported on simulators") throw PushRegistrationError.pushNotSupported(description: "Push not supported on simulators")
} }
return self.registerForVanillaPushToken().then { vanillaPushToken -> Promise<(pushToken: String, voipToken: String)> in return self.registerForVanillaPushToken().map { vanillaPushToken -> (pushToken: String, voipToken: String) in
self.registerForVoipPushToken().map { voipPushToken in return (pushToken: vanillaPushToken, voipToken: "")
(pushToken: vanillaPushToken, voipToken: voipPushToken)
}
} }
} }
} }

@ -300,8 +300,9 @@ NSString *const TSAccountManager_NeedsAccountAttributesUpdateKey = @"TSAccountMa
remainingRetries:(int)remainingRetries remainingRetries:(int)remainingRetries
{ {
BOOL isUsingFullAPNs = [NSUserDefaults.standardUserDefaults boolForKey:@"isUsingFullAPNs"]; BOOL isUsingFullAPNs = [NSUserDefaults.standardUserDefaults boolForKey:@"isUsingFullAPNs"];
AnyPromise *promise = isUsingFullAPNs ? [LKPushNotificationManager registerWithToken:pushToken hexEncodedPublicKey:self.localNumber isForcedUpdate:isForcedUpdate] NSData *pushTokenAsData = [NSData dataFromHexString:pushToken];
: [LKPushNotificationManager registerWithToken:pushToken isForcedUpdate:isForcedUpdate]; AnyPromise *promise = isUsingFullAPNs ? [LKPushNotificationManager registerWithToken:pushTokenAsData hexEncodedPublicKey:self.localNumber isForcedUpdate:isForcedUpdate]
: [LKPushNotificationManager registerWithToken:pushTokenAsData isForcedUpdate:isForcedUpdate];
promise promise
.then(^() { .then(^() {
successHandler(); successHandler();

Loading…
Cancel
Save