diff --git a/Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift b/Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift index f9d810acf..966c5dd65 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift +++ b/Signal/src/ViewControllers/DebugUI/DebugUINotifications.swift @@ -36,11 +36,15 @@ class DebugUINotifications: DebugUIPage { } var sectionItems = [ - OWSTableItem(title:"Last Incoming Message") { - Logger.info("\(self.logTag) scheduling notification for incoming message.") - self.delayedNotificationDispatch { - Logger.info("\(self.logTag) dispatching") - TSStorageManager.shared().newDatabaseConnection().read({ (transaction) in + OWSTableItem(title:"Last Incoming Message") { [weak self] in + guard let strongSelf = self else { + return + } + + Logger.info("\(strongSelf.logTag) scheduling notification for incoming message.") + strongSelf.delayedNotificationDispatch { + Logger.info("\(strongSelf.logTag) dispatching") + TSStorageManager.shared().newDatabaseConnection().read { (transaction) in guard let viewTransaction = transaction.ext(TSMessageDatabaseViewExtensionName) as? YapDatabaseViewTransaction else { owsFail("unable to build view transaction") return @@ -55,28 +59,40 @@ class DebugUINotifications: DebugUIPage { owsFail("last message was not an incoming message.") return } - Logger.info("\(self.logTag) notifying user of incoming message") - self.notificationsManager.notifyUser(for: incomingMessage, in: thread, contactsManager: self.contactsManager, transaction: transaction) - }) + Logger.info("\(strongSelf.logTag) notifying user of incoming message") + strongSelf.notificationsManager.notifyUser(for: incomingMessage, in: thread, contactsManager: strongSelf.contactsManager, transaction: transaction) + } } } ] if let contactThread = thread as? TSContactThread { sectionItems += [ - OWSTableItem(title:"Call Missed") { - self.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in - self.notificationsAdapter.presentMissedCall(call, callerName: thread.name()) + OWSTableItem(title:"Call Missed") { [weak self] in + guard let strongSelf = self else { + return + } + + strongSelf.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in + strongSelf.notificationsAdapter.presentMissedCall(call, callerName: thread.name()) } }, - OWSTableItem(title:"Call Rejected: New Safety Number") { - self.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in - self.notificationsAdapter.presentMissedCallBecauseOfNewIdentity(call: call, callerName: thread.name()) + OWSTableItem(title:"Call Rejected: New Safety Number") { [weak self] in + guard let strongSelf = self else { + return + } + + strongSelf.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in + strongSelf.notificationsAdapter.presentMissedCallBecauseOfNewIdentity(call: call, callerName: thread.name()) } }, - OWSTableItem(title:"Call Rejected: No Longer Verified") { - self.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in - self.notificationsAdapter.presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: call, callerName: thread.name()) + OWSTableItem(title:"Call Rejected: No Longer Verified") { [weak self] in + guard let strongSelf = self else { + return + } + + strongSelf.delayedNotificationDispatchWithFakeCall(thread: contactThread) { call in + strongSelf.notificationsAdapter.presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: call, callerName: thread.name()) } } ] diff --git a/SignalMessaging/utils/DisplayableText.swift b/SignalMessaging/utils/DisplayableText.swift index cdfc21bbb..b8a888581 100644 --- a/SignalMessaging/utils/DisplayableText.swift +++ b/SignalMessaging/utils/DisplayableText.swift @@ -221,8 +221,11 @@ extension String { return nil } - // Notifications strip anything that looks lik a printf formatting character, - // so literal "%" must be escaped in order to appear in notification text. + // iOS strips anything that looks like a printf formatting character from + // the notification body, so if we want to dispay a literal "%" in a notification + // it must be escaped. + // see https://developer.apple.com/documentation/uikit/uilocalnotification/1616646-alertbody + // for more details. return text.replacingOccurrences(of: "%", with: "%%") }