mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Merge pull request #3578 from vector-im/element_3577
Remove PushKit Pushers
This commit is contained in:
commit
bb3ff97cb1
2 changed files with 25 additions and 6 deletions
|
@ -8,7 +8,8 @@ Improvements:
|
|||
*
|
||||
|
||||
Bugfix:
|
||||
* Update room input toolbar on theme change (#3445).
|
||||
* Update room input toolbar on theme change (#3445).
|
||||
* Explicitly remove PushKit pushers (#3577).
|
||||
|
||||
API Change:
|
||||
*
|
||||
|
|
|
@ -104,14 +104,32 @@ Matrix session observer used to detect new opened sessions.
|
|||
{
|
||||
MXKAccountManager* accountManager = [MXKAccountManager sharedManager];
|
||||
[accountManager setApnsDeviceToken:deviceToken];
|
||||
// remove PushKit pusher if exists
|
||||
|
||||
// remove PushKit pusher
|
||||
if (!accountManager.pushDeviceToken)
|
||||
{
|
||||
// If we don't have the pushDeviceToken, we may have migrated it into the shared user defaults.
|
||||
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.
|
||||
[[NSUserDefaults standardUserDefaults] setObject:pushDeviceToken forKey:@"pushDeviceToken"];
|
||||
}
|
||||
}
|
||||
|
||||
// if we already have pushDeviceToken or recovered it in above step
|
||||
if (accountManager.pushDeviceToken)
|
||||
{
|
||||
[accountManager setPushDeviceToken:nil withPushOptions:nil];
|
||||
// Attempt to remove PushKit pushers explicitly
|
||||
[[accountManager accounts] enumerateObjectsUsingBlock:^(MXKAccount * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[obj enablePushKitNotifications:NO success:^{
|
||||
[MXKAppSettings.standardAppSettings.sharedUserDefaults removeObjectForKey:@"pushDeviceToken"];
|
||||
[MXKAppSettings.standardAppSettings.sharedUserDefaults removeObjectForKey:@"pushOptions"];
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"pushDeviceToken"];
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"pushOptions"];
|
||||
} failure:nil];
|
||||
}];
|
||||
}
|
||||
// Sanity check: Make sure the Pushkit push token is deleted
|
||||
NSParameterAssert(!accountManager.isPushAvailable);
|
||||
NSParameterAssert(!accountManager.pushDeviceToken);
|
||||
|
||||
_isPushRegistered = YES;
|
||||
|
||||
|
|
Loading…
Reference in a new issue