Unregister the user from APNs when they clear their account

This commit is contained in:
nielsandriesse 2020-08-03 09:10:24 +10:00
parent 5f98392803
commit ad8cb4f243

View file

@ -936,6 +936,13 @@ static NSTimeInterval launchStartedAt;
- (void)handleDataNukeRequested:(NSNotification *)notification
{
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
BOOL isUsingFullAPNs = [userDefaults boolForKey:@"isUsingFullAPNs"];
NSString *hexEncodedDeviceToken = [userDefaults stringForKey:@"deviceToken"];
if (isUsingFullAPNs && hexEncodedDeviceToken != nil) {
NSData *deviceToken = [NSData dataFromHexString:hexEncodedDeviceToken];
[[LKPushNotificationManager registerWithToken:deviceToken isForcedUpdate:YES] retainUntilComplete]; // This actually unregisters the user; we should rename the function
}
[ThreadUtil deleteAllContent];
[SSKEnvironment.shared.messageSenderJobQueue clearAllJobs];
[SSKEnvironment.shared.identityManager clearIdentityKey];