From cd298c72c303b85fd98b0cccbf2f1c6ee7b0a176 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 4 Jun 2018 12:00:45 -0600 Subject: [PATCH] notify when receiving voip before first unlock // FREEBIE --- Signal/src/AppDelegate.m | 15 +++++++++++++++ Signal/translations/en.lproj/Localizable.strings | 3 +++ 2 files changed, 18 insertions(+) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 890a13395..be9a3d338 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -231,6 +231,21 @@ static NSTimeInterval launchStartedAt; if (![OWSPrimaryStorage isDatabasePasswordAccessible]) { DDLogInfo( @"%@ exiting because we are in the background and the database password is not accessible.", self.logTag); + + UILocalNotification *notification = [UILocalNotification new]; + NSString *messageFormat = NSLocalizedString(@"NOTIFICATION_BODY_PHONE_LOCKED_FORMAT", + @"Lock screen notification text presented after user powers on their device without unlocking. Embeds " + @"{{device model}} (either 'iPad' or 'iPhone')"); + notification.alertBody = [NSString stringWithFormat:messageFormat, UIDevice.currentDevice.localizedModel]; + + // Make sure we clear any existing notifications so that they don't start stacking up + // if the user receives multiple pushes. + [UIApplication.sharedApplication cancelAllLocalNotifications]; + [UIApplication.sharedApplication setApplicationIconBadgeNumber:0]; + + [[UIApplication sharedApplication] scheduleLocalNotification:notification]; + [UIApplication.sharedApplication setApplicationIconBadgeNumber:1]; + [DDLog flushLog]; exit(0); } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index bae7012ed..86061cd13 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1345,6 +1345,9 @@ /* Label for a button that lets users search for contacts by phone number */ "NO_CONTACTS_SEARCH_BY_PHONE_NUMBER" = "Find Contacts by Phone Number"; +/* Lock screen notification text presented after user powers on their device without unlocking. Embeds {{device model}} (either 'iPad' or 'iPhone') */ +"NOTIFICATION_BODY_PHONE_LOCKED_FORMAT" = "You must unlock your %@ once after restarting to receive Signal messages."; + /* No comment provided by engineer. */ "NOTIFICATION_SEND_FAILED" = "Your message failed to send to %@.";