Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

PushKit: Delete any pending PushKit pusher #711

Merged
merged 5 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: Delete any pending PushKit pusher (vector-im/riot-ios/issues/3577).

API Change:
*
Expand Down
4 changes: 0 additions & 4 deletions MatrixKit/Controllers/MXKAuthenticationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ - (void)viewDidLoad
[_cancelAuthFallbackButton setTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] forState:UIControlStateHighlighted];
}

- (void)dealloc
{
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
Expand Down
49 changes: 37 additions & 12 deletions MatrixKit/Models/Account/MXKAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
}
}
}

Expand Down Expand Up @@ -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];
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions MatrixKit/Models/Account/MXKAccountManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ - (void)setApnsDeviceToken:(NSData *)apnsDeviceToken
}
}
}
else
{
NSLog(@"[MXKAccountManager][Push] setApnsDeviceToken: Same token. Nothing to do.");
}
}
}

Expand Down Expand Up @@ -542,6 +546,10 @@ - (void)setPushDeviceToken:(NSData *)pushDeviceToken withPushOptions:(NSDictiona
}
}
}
else
{
NSLog(@"[MXKAccountManager][Push] setPushDeviceToken: Same token. Nothing to do.");
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions MatrixKit/Models/MXKAppSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ -(instancetype)init
return self;
}

- (void)dealloc
{
}

- (void)reset
{
if (self == [MXKAppSettings standardAppSettings])
Expand Down
4 changes: 0 additions & 4 deletions MatrixKit/Models/Room/MXKRoomBubbleComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions MatrixKit/Views/RoomTitle/MXKRoomTitleViewWithTopic.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ - (void)awakeFromNib
self.hiddenTopic = YES;
}

- (void)dealloc
{
}

- (void)refreshDisplay
{
[super refreshDisplay];
Expand Down