mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Sync push tokens on background launch as well
// FREEBIE
This commit is contained in:
parent
abcf421eff
commit
c7cfe188ee
|
@ -271,23 +271,26 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
||||||
|
|
||||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
||||||
{
|
{
|
||||||
DDLogDebug(@"%@ Successfully registered for remote notifications with token: %@", self.tag, deviceToken);
|
DDLogDebug(@"%@ registered vanilla push token: %@", self.tag, deviceToken);
|
||||||
[PushManager.sharedManager.pushNotificationFutureSource trySetResult:deviceToken];
|
[PushManager.sharedManager.pushNotificationFutureSource trySetResult:deviceToken];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
||||||
{
|
{
|
||||||
OWSProdError([OWSAnalyticsEvents appDelegateErrorFailedToRegisterForRemoteNotifications]);
|
DDLogDebug(@"%@ failed to register vanilla push token with error: %@", self.tag, error);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
DDLogWarn(@"%@ We're in debug mode. Faking success for remote registration with a fake push identifier", self.tag);
|
DDLogWarn(@"%@ We're in debug mode. Faking success for remote registration with a fake push identifier", self.tag);
|
||||||
[PushManager.sharedManager.pushNotificationFutureSource trySetResult:[[NSMutableData dataWithLength:32] copy]];
|
[PushManager.sharedManager.pushNotificationFutureSource trySetResult:[[NSMutableData dataWithLength:32] copy]];
|
||||||
#else
|
#else
|
||||||
|
OWSProdError([OWSAnalyticsEvents appDelegateErrorFailedToRegisterForRemoteNotifications]);
|
||||||
[PushManager.sharedManager.pushNotificationFutureSource trySetFailure:error];
|
[PushManager.sharedManager.pushNotificationFutureSource trySetFailure:error];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)application:(UIApplication *)application
|
- (void)application:(UIApplication *)application
|
||||||
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
|
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
|
||||||
|
{
|
||||||
|
DDLogDebug(@"%@ registered user notification settings", self.tag);
|
||||||
[PushManager.sharedManager.userNotificationFutureSource trySetResult:notificationSettings];
|
[PushManager.sharedManager.userNotificationFutureSource trySetResult:notificationSettings];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,12 +483,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
||||||
// At this point, potentially lengthy DB locking migrations could be running.
|
// At this point, potentially lengthy DB locking migrations could be running.
|
||||||
// Avoid blocking app launch by putting all further possible DB access in async block
|
// Avoid blocking app launch by putting all further possible DB access in async block
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
DDLogInfo(
|
DDLogInfo(@"%@ running post launch block for registered user: %@", self.tag, [TSAccountManager localNumber]);
|
||||||
@"%@ running post launch block for registered user: %@", self.tag, [TSAccountManager localNumber]);
|
|
||||||
__unused AnyPromise *promise =
|
|
||||||
[OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
|
|
||||||
accountManager:[Environment getCurrent].accountManager
|
|
||||||
preferences:[Environment preferences]];
|
|
||||||
|
|
||||||
// Clean up any messages that expired since last launch immediately
|
// Clean up any messages that expired since last launch immediately
|
||||||
// and continue cleaning in the background.
|
// and continue cleaning in the background.
|
||||||
|
@ -819,6 +817,11 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
|
||||||
|
|
||||||
if ([TSAccountManager isRegistered]) {
|
if ([TSAccountManager isRegistered]) {
|
||||||
DDLogInfo(@"localNumber: %@", [TSAccountManager localNumber]);
|
DDLogInfo(@"localNumber: %@", [TSAccountManager localNumber]);
|
||||||
|
|
||||||
|
// This should happen at any launch, background or foreground.
|
||||||
|
__unused AnyPromise *promise = [OWSSyncPushTokensJob runWithPushManager:[PushManager sharedManager]
|
||||||
|
accountManager:[Environment getCurrent].accountManager
|
||||||
|
preferences:[Environment preferences]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[DeviceSleepManager.sharedInstance removeBlockWithBlockObject:self];
|
[DeviceSleepManager.sharedInstance removeBlockWithBlockObject:self];
|
||||||
|
|
Loading…
Reference in a new issue