diff --git a/CHANGES.rst b/CHANGES.rst index 250709ac1..630a0f8f5 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,7 +8,7 @@ Improvements: * Bugfix: - * + * PushKit: Delete any pending PushKit pusher (vector-im/riot-ios/issues/3577). API Change: * diff --git a/MatrixKit/Controllers/MXKAuthenticationViewController.m b/MatrixKit/Controllers/MXKAuthenticationViewController.m index 8ecfd29a0..73a67e54a 100644 --- a/MatrixKit/Controllers/MXKAuthenticationViewController.m +++ b/MatrixKit/Controllers/MXKAuthenticationViewController.m @@ -173,10 +173,6 @@ - (void)viewDidLoad [_cancelAuthFallbackButton setTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] forState:UIControlStateHighlighted]; } -- (void)dealloc -{ -} - - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; diff --git a/MatrixKit/Models/Account/MXKAccount.m b/MatrixKit/Models/Account/MXKAccount.m index 55993c706..f3ce75d81 100644 --- a/MatrixKit/Models/Account/MXKAccount.m +++ b/MatrixKit/Models/Account/MXKAccount.m @@ -534,6 +534,11 @@ - (void)enablePushKitNotifications:(BOOL)enable } }]; } + else + { + NSLog(@"[MXKAccount][Push] enablePushKitNotifications: PushKit is already disabled for %@", self.mxCredentials.userId); + success(); + } } - (void)setEnableInAppNotifications:(BOOL)enableInAppNotifications @@ -1159,11 +1164,23 @@ - (void)refreshAPNSPusher NSLog(@"[MXKAccount][Push] ;: Error: %@", error); }]; } - else if (_hasPusherForPushNotifications && mxSession) + else if (_hasPusherForPushNotifications) { - // Turn off pusher if user denied remote notification. - NSLog(@"[MXKAccount][Push] refreshAPNSPusher: Disable APNS pusher for %@ account (notifications are denied)", self.mxCredentials.userId); - [self enableAPNSPusher:NO success:nil failure:nil]; + if ([MXKAccountManager sharedManager].apnsDeviceToken) + { + if (mxSession) + { + // Turn off pusher if user denied remote notification. + NSLog(@"[MXKAccount][Push] refreshAPNSPusher: Disable APNS pusher for %@ account (notifications are denied)", self.mxCredentials.userId); + [self enableAPNSPusher:NO success:nil failure:nil]; + } + } + else + { + NSLog(@"[MXKAccount][Push] refreshAPNSPusher: APNS pusher for %@ account is already disabled. Reset _hasPusherForPushNotifications", self.mxCredentials.userId); + _hasPusherForPushNotifications = NO; + [[MXKAccountManager sharedManager] saveAccounts]; + } } } @@ -1253,15 +1270,23 @@ - (void)refreshPushKitPusher NSLog(@"[MXKAccount][Push] refreshPushKitPusher: Error: %@", error); }]; } - else if (_hasPusherForPushKitNotifications && mxSession) + else if (_hasPusherForPushKitNotifications) { - NSLog(@"[MXKAccount][Push] refreshPushKitPusher: Do nothing. User denied notifications (account: %@)", self.mxCredentials.userId); - - // XXX: The following code has been commented to avoid automatic deactivation of push notifications - - // Turn off pusher if user denied remote notification. - //NSLog(@"[MXKAccount][Push] refreshPushKitPusher: Disable PushKit pusher for %@ account (notifications are denied)", self.mxCredentials.userId); - //[self enablePushKitPusher:NO success:nil failure:nil]; + if ([MXKAccountManager sharedManager].pushDeviceToken) + { + if (mxSession) + { + // Turn off pusher if user denied remote notification. + NSLog(@"[MXKAccount][Push] refreshPushKitPusher: Disable PushKit pusher for %@ account (notifications are denied)", self.mxCredentials.userId); + [self enablePushKitPusher:NO success:nil failure:nil]; + } + } + else + { + NSLog(@"[MXKAccount][Push] refreshPushKitPusher: PushKit pusher for %@ account is already disabled. Reset _hasPusherForPushKitNotifications", self.mxCredentials.userId); + _hasPusherForPushKitNotifications = NO; + [[MXKAccountManager sharedManager] saveAccounts]; + } } } diff --git a/MatrixKit/Models/Account/MXKAccountManager.m b/MatrixKit/Models/Account/MXKAccountManager.m index ee1a08ae7..44493b63a 100644 --- a/MatrixKit/Models/Account/MXKAccountManager.m +++ b/MatrixKit/Models/Account/MXKAccountManager.m @@ -402,6 +402,10 @@ - (void)setApnsDeviceToken:(NSData *)apnsDeviceToken } } } + else + { + NSLog(@"[MXKAccountManager][Push] setApnsDeviceToken: Same token. Nothing to do."); + } } } @@ -542,6 +546,10 @@ - (void)setPushDeviceToken:(NSData *)pushDeviceToken withPushOptions:(NSDictiona } } } + else + { + NSLog(@"[MXKAccountManager][Push] setPushDeviceToken: Same token. Nothing to do."); + } } } diff --git a/MatrixKit/Models/MXKAppSettings.m b/MatrixKit/Models/MXKAppSettings.m index cfe225e2a..1a743291b 100644 --- a/MatrixKit/Models/MXKAppSettings.m +++ b/MatrixKit/Models/MXKAppSettings.m @@ -169,10 +169,6 @@ -(instancetype)init return self; } -- (void)dealloc -{ -} - - (void)reset { if (self == [MXKAppSettings standardAppSettings]) diff --git a/MatrixKit/Models/Room/MXKRoomBubbleComponent.m b/MatrixKit/Models/Room/MXKRoomBubbleComponent.m index 8b80e7649..edc3971ad 100644 --- a/MatrixKit/Models/Room/MXKRoomBubbleComponent.m +++ b/MatrixKit/Models/Room/MXKRoomBubbleComponent.m @@ -63,10 +63,6 @@ - (instancetype)initWithEvent:(MXEvent*)event roomState:(MXRoomState*)roomState return self; } -- (void)dealloc -{ -} - - (void)updateWithEvent:(MXEvent*)event roomState:(MXRoomState*)roomState session:(MXSession*)session { // Report the new event diff --git a/MatrixKit/Views/RoomTitle/MXKRoomTitleViewWithTopic.m b/MatrixKit/Views/RoomTitle/MXKRoomTitleViewWithTopic.m index bc524b0ad..23fec6409 100644 --- a/MatrixKit/Views/RoomTitle/MXKRoomTitleViewWithTopic.m +++ b/MatrixKit/Views/RoomTitle/MXKRoomTitleViewWithTopic.m @@ -58,10 +58,6 @@ - (void)awakeFromNib self.hiddenTopic = YES; } -- (void)dealloc -{ -} - - (void)refreshDisplay { [super refreshDisplay];