From ad8cb4f243be164f9184bb4de81b234f8591b9aa Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 3 Aug 2020 09:10:24 +1000 Subject: [PATCH] Unregister the user from APNs when they clear their account --- Signal/src/AppDelegate.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 4c4767cea..d00367ab4 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -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];