Fix race condition

pull/233/head
nielsandriesse 5 years ago
parent f1581b4edf
commit a16f30dc39

@ -16,9 +16,9 @@ final class NotificationServiceExtension : UNNotificationServiceExtension {
self.contentHandler = contentHandler
notificationContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
DispatchQueue.main.sync { self.setUpIfNecessary() }
if let notificationContent = notificationContent {
DispatchQueue.main.async {
self.setUpIfNecessary() {
if let notificationContent = self.notificationContent {
// Modify the notification content here...
let base64EncodedData = notificationContent.userInfo["ENCRYPTED_DATA"] as! String
let data = Data(base64Encoded: base64EncodedData)!
@ -42,6 +42,8 @@ final class NotificationServiceExtension : UNNotificationServiceExtension {
}
}
}
}
}
func handleDecryptionResult(result: OWSMessageDecryptResult, notificationContent: UNMutableNotificationContent, transaction: YapDatabaseReadWriteTransaction) {
let contentProto = try? SSKProtoContent.parseData(result.plaintextData!)
@ -96,7 +98,7 @@ final class NotificationServiceExtension : UNNotificationServiceExtension {
}
}
func setUpIfNecessary() {
func setUpIfNecessary(completion: @escaping () -> Void) {
AssertIsOnMainThread()
// The NSE will often re-use the same process, so if we're
@ -132,6 +134,7 @@ final class NotificationServiceExtension : UNNotificationServiceExtension {
},
migrationCompletion: { [weak self] in
self?.versionMigrationsDidComplete()
completion()
}
)

Loading…
Cancel
Save