Skip to content

Commit

Permalink
PushKit pusher: Add more logs when removing it
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed Aug 31, 2020
1 parent f3e11a4 commit 3dec5d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Improvements:
*

Bugfix:
*
* PushKit pusher: Add more logs when removing it (#3577).

API Change:
*
Expand Down
10 changes: 9 additions & 1 deletion Riot/Managers/PushNotification/PushNotificationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,22 @@ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
NSString *pushDeviceToken = [MXKAppSettings.standardAppSettings.sharedUserDefaults objectForKey:@"pushDeviceToken"];
if (pushDeviceToken)
{
// Set the token in standard user defaults, as MXKAccount will read it from there when removing the pusher.
NSLog(@"[PushNotificationService][Push] didRegisterForRemoteNotificationsWithDeviceToken: Move PushKit token to user defaults");

// Set the token in standard user defaults, as MXKAccount will read it from there when removing the pusher.
// This will allow to remove the PushKit pusher in the next step
[[NSUserDefaults standardUserDefaults] setObject:pushDeviceToken forKey:@"pushDeviceToken"];

[MXKAppSettings.standardAppSettings.sharedUserDefaults removeObjectForKey:@"pushDeviceToken"];
[MXKAppSettings.standardAppSettings.sharedUserDefaults removeObjectForKey:@"pushOptions"];
}
}

// if we already have pushDeviceToken or recovered it in above step
if (accountManager.pushDeviceToken)
{
NSLog(@"[PushNotificationService][Push] didRegisterForRemoteNotificationsWithDeviceToken: A PushKit pusher still exists. Remove it");

// Attempt to remove PushKit pushers explicitly
[[accountManager accounts] enumerateObjectsUsingBlock:^(MXKAccount * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[obj enablePushKitNotifications:NO success:^{
Expand Down

0 comments on commit 3dec5d9

Please sign in to comment.