Use new message receiving pipeline in PN extension
This commit is contained in:
parent
000249b744
commit
75b184c0b9
|
@ -512,17 +512,6 @@ static NSTimeInterval launchStartedAt;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
// A bug in orphan cleanup could be disastrous so let's only
|
|
||||||
// run it in DEBUG builds for a few releases.
|
|
||||||
//
|
|
||||||
// TODO: Release to production once we have analytics.
|
|
||||||
// TODO: Orphan cleanup is somewhat expensive - not least in doing a bunch
|
|
||||||
// TODO: of disk access. We might want to only run it "once per version"
|
|
||||||
// TODO: or something like that in production.
|
|
||||||
[OWSOrphanDataCleaner auditOnLaunchIfNecessary];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[self.readReceiptManager prepareCachedValues];
|
[self.readReceiptManager prepareCachedValues];
|
||||||
|
|
||||||
// Disable the SAE until the main app has successfully completed launch process
|
// Disable the SAE until the main app has successfully completed launch process
|
||||||
|
|
|
@ -7,7 +7,7 @@ extension MessageReceiver {
|
||||||
return SSKEnvironment.shared.blockingManager.isRecipientIdBlocked(publicKey)
|
return SSKEnvironment.shared.blockingManager.isRecipientIdBlocked(publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static func handle(_ message: Message, associatedWithProto proto: SNProtoContent, openGroupID: String?, using transaction: Any) throws {
|
public static func handle(_ message: Message, associatedWithProto proto: SNProtoContent, openGroupID: String?, using transaction: Any) throws {
|
||||||
switch message {
|
switch message {
|
||||||
case let message as ReadReceipt: handleReadReceipt(message, using: transaction)
|
case let message as ReadReceipt: handleReadReceipt(message, using: transaction)
|
||||||
case let message as TypingIndicator: handleTypingIndicator(message, using: transaction)
|
case let message as TypingIndicator: handleTypingIndicator(message, using: transaction)
|
||||||
|
@ -135,7 +135,8 @@ extension MessageReceiver {
|
||||||
SSKEnvironment.shared.disappearingMessagesJob.startIfNecessary()
|
SSKEnvironment.shared.disappearingMessagesJob.startIfNecessary()
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func handleVisibleMessage(_ message: VisibleMessage, associatedWithProto proto: SNProtoContent, openGroupID: String?, using transaction: Any) throws {
|
@discardableResult
|
||||||
|
public static func handleVisibleMessage(_ message: VisibleMessage, associatedWithProto proto: SNProtoContent, openGroupID: String?, using transaction: Any) throws -> String {
|
||||||
let storage = Configuration.shared.storage
|
let storage = Configuration.shared.storage
|
||||||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
||||||
// Parse & persist attachments
|
// Parse & persist attachments
|
||||||
|
@ -188,21 +189,23 @@ extension MessageReceiver {
|
||||||
groupPublicKey: message.groupPublicKey, openGroupID: openGroupID, using: transaction) else { throw Error.noThread }
|
groupPublicKey: message.groupPublicKey, openGroupID: openGroupID, using: transaction) else { throw Error.noThread }
|
||||||
message.threadID = threadID
|
message.threadID = threadID
|
||||||
// Start attachment downloads if needed
|
// Start attachment downloads if needed
|
||||||
storage.withAsync({ transaction in
|
|
||||||
attachmentsToDownload.forEach { attachmentID in
|
attachmentsToDownload.forEach { attachmentID in
|
||||||
let downloadJob = AttachmentDownloadJob(attachmentID: attachmentID, tsIncomingMessageID: tsIncomingMessageID)
|
let downloadJob = AttachmentDownloadJob(attachmentID: attachmentID, tsIncomingMessageID: tsIncomingMessageID)
|
||||||
if CurrentAppContext().isMainAppAndActive { // This has to be called from the main thread
|
if CurrentAppContext().isMainAppAndActive {
|
||||||
JobQueue.shared.add(downloadJob, using: transaction)
|
JobQueue.shared.add(downloadJob, using: transaction)
|
||||||
} else {
|
} else {
|
||||||
JobQueue.shared.addWithoutExecuting(downloadJob, using: transaction)
|
JobQueue.shared.addWithoutExecuting(downloadJob, using: transaction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, completion: { })
|
// Cancel any typing indicators if needed
|
||||||
// Cancel any typing indicators
|
if CurrentAppContext().isMainAppAndActive {
|
||||||
cancelTypingIndicatorsIfNeeded(for: message.sender!)
|
cancelTypingIndicatorsIfNeeded(for: message.sender!)
|
||||||
|
}
|
||||||
// Notify the user if needed
|
// Notify the user if needed
|
||||||
guard let tsIncomingMessage = TSIncomingMessage.fetch(uniqueId: tsIncomingMessageID, transaction: transaction), let thread = TSThread.fetch(uniqueId: threadID, transaction: transaction) else { return }
|
guard CurrentAppContext().isMainAppAndActive, let tsIncomingMessage = TSIncomingMessage.fetch(uniqueId: tsIncomingMessageID, transaction: transaction),
|
||||||
|
let thread = TSThread.fetch(uniqueId: threadID, transaction: transaction) else { return tsIncomingMessageID }
|
||||||
SSKEnvironment.shared.notificationsManager!.notifyUser(for: tsIncomingMessage, in: thread, transaction: transaction)
|
SSKEnvironment.shared.notificationsManager!.notifyUser(for: tsIncomingMessage, in: thread, transaction: transaction)
|
||||||
|
return tsIncomingMessageID
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func handleClosedGroupUpdate(_ message: ClosedGroupUpdate, using transaction: Any) {
|
private static func handleClosedGroupUpdate(_ message: ClosedGroupUpdate, using transaction: Any) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import SessionUtilitiesKit
|
import SessionUtilitiesKit
|
||||||
|
|
||||||
internal enum MessageReceiver {
|
public enum MessageReceiver {
|
||||||
|
|
||||||
internal enum Error : LocalizedError {
|
public enum Error : LocalizedError {
|
||||||
case duplicateMessage
|
case duplicateMessage
|
||||||
case invalidMessage
|
case invalidMessage
|
||||||
case unknownMessage
|
case unknownMessage
|
||||||
|
@ -17,14 +17,14 @@ internal enum MessageReceiver {
|
||||||
case noGroupPrivateKey
|
case noGroupPrivateKey
|
||||||
case sharedSecretGenerationFailed
|
case sharedSecretGenerationFailed
|
||||||
|
|
||||||
internal var isRetryable: Bool {
|
public var isRetryable: Bool {
|
||||||
switch self {
|
switch self {
|
||||||
case .duplicateMessage, .invalidMessage, .unknownMessage, .unknownEnvelopeType, .noData, .senderBlocked, .selfSend: return false
|
case .duplicateMessage, .invalidMessage, .unknownMessage, .unknownEnvelopeType, .noData, .senderBlocked, .selfSend: return false
|
||||||
default: return true
|
default: return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var errorDescription: String? {
|
public var errorDescription: String? {
|
||||||
switch self {
|
switch self {
|
||||||
case .duplicateMessage: return "Duplicate message."
|
case .duplicateMessage: return "Duplicate message."
|
||||||
case .invalidMessage: return "Invalid message."
|
case .invalidMessage: return "Invalid message."
|
||||||
|
@ -43,7 +43,7 @@ internal enum MessageReceiver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static func parse(_ data: Data, openGroupMessageServerID: UInt64?, using transaction: Any) throws -> (Message, SNProtoContent) {
|
public static func parse(_ data: Data, openGroupMessageServerID: UInt64?, using transaction: Any) throws -> (Message, SNProtoContent) {
|
||||||
let userPublicKey = Configuration.shared.storage.getUserPublicKey()
|
let userPublicKey = Configuration.shared.storage.getUserPublicKey()
|
||||||
let isOpenGroupMessage = (openGroupMessageServerID != nil)
|
let isOpenGroupMessage = (openGroupMessageServerID != nil)
|
||||||
// Parse the envelope
|
// Parse the envelope
|
||||||
|
|
|
@ -1,157 +1,74 @@
|
||||||
import UserNotifications
|
import UserNotifications
|
||||||
|
import SessionMessagingKit
|
||||||
import SignalUtilitiesKit
|
import SignalUtilitiesKit
|
||||||
|
|
||||||
|
// TODO: Group notifications
|
||||||
|
|
||||||
final class NotificationServiceExtension : UNNotificationServiceExtension {
|
final class NotificationServiceExtension : UNNotificationServiceExtension {
|
||||||
static let isFromRemoteKey = "remote"
|
|
||||||
static let threadIdKey = "Signal.AppNotificationsUserInfoKey.threadId"
|
|
||||||
|
|
||||||
private var didPerformSetup = false
|
private var didPerformSetup = false
|
||||||
|
private var areVersionMigrationsComplete = false
|
||||||
|
private var contentHandler: ((UNNotificationContent) -> Void)?
|
||||||
|
private var notificationContent: UNMutableNotificationContent?
|
||||||
|
|
||||||
var areVersionMigrationsComplete = false
|
private static let isFromRemoteKey = "remote"
|
||||||
var contentHandler: ((UNNotificationContent) -> Void)?
|
private static let threadIdKey = "Signal.AppNotificationsUserInfoKey.threadId"
|
||||||
var notificationContent: UNMutableNotificationContent?
|
|
||||||
|
|
||||||
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||||
self.contentHandler = contentHandler
|
self.contentHandler = contentHandler
|
||||||
notificationContent = request.content.mutableCopy() as? UNMutableNotificationContent
|
self.notificationContent = request.content.mutableCopy() as? UNMutableNotificationContent
|
||||||
|
|
||||||
|
// Abort if the main app is running
|
||||||
var isMainAppActive = false
|
var isMainAppActive = false
|
||||||
if let sharedUserDefaults = UserDefaults(suiteName: "group.com.loki-project.loki-messenger") {
|
if let sharedUserDefaults = UserDefaults(suiteName: "group.com.loki-project.loki-messenger") {
|
||||||
isMainAppActive = sharedUserDefaults.bool(forKey: "isMainAppActive")
|
isMainAppActive = sharedUserDefaults.bool(forKey: "isMainAppActive")
|
||||||
}
|
}
|
||||||
// If the main app is running, skip the whole process
|
guard !isMainAppActive else { return self.handleFailure(for: notificationContent!) }
|
||||||
guard !isMainAppActive else { return self.completeWithFailure(content: notificationContent!) }
|
|
||||||
|
|
||||||
// The code using DispatchQueue.main.async { self.setUpIfNecessary() { Modify the notification content } } will somehow cause a freeze when a second PN comes
|
|
||||||
|
|
||||||
|
// Perform main setup
|
||||||
DispatchQueue.main.sync { self.setUpIfNecessary() { } }
|
DispatchQueue.main.sync { self.setUpIfNecessary() { } }
|
||||||
|
|
||||||
|
// Handle the push notification
|
||||||
AppReadiness.runNowOrWhenAppDidBecomeReady {
|
AppReadiness.runNowOrWhenAppDidBecomeReady {
|
||||||
if let notificationContent = self.notificationContent {
|
let notificationContent = self.notificationContent!
|
||||||
// Modify the notification content here...
|
guard let base64EncodedData = notificationContent.userInfo["ENCRYPTED_DATA"] as! String?, let data = Data(base64Encoded: base64EncodedData),
|
||||||
let base64EncodedData = notificationContent.userInfo["ENCRYPTED_DATA"] as! String
|
let envelope = try? MessageWrapper.unwrap(data: data), let envelopeAsData = try? envelope.serializedData() else {
|
||||||
let data = Data(base64Encoded: base64EncodedData)!
|
return self.handleFailure(for: notificationContent)
|
||||||
if let envelope = try? MessageWrapper.unwrap(data: data), let data = try? envelope.serializedData() {
|
|
||||||
// TODO TODO TODO
|
|
||||||
|
|
||||||
/*
|
|
||||||
decrypter.decryptEnvelope(envelope,
|
|
||||||
envelopeData: data,
|
|
||||||
successBlock: { result, transaction in
|
|
||||||
if let envelope = try? SNProtoEnvelope.parseData(result.envelopeData) {
|
|
||||||
messageManager.throws_processEnvelope(envelope, plaintextData: result.plaintextData, wasReceivedByUD: wasReceivedByUD, transaction: transaction, serverID: 0)
|
|
||||||
self.handleDecryptionResult(result: result, notificationContent: notificationContent, transaction: transaction)
|
|
||||||
} else {
|
|
||||||
self.completeWithFailure(content: notificationContent)
|
|
||||||
}
|
}
|
||||||
},
|
Storage.write { transaction in // Intentionally capture self
|
||||||
failureBlock: {
|
do {
|
||||||
self.completeWithFailure(content: notificationContent)
|
let (message, proto) = try MessageReceiver.parse(envelopeAsData, openGroupMessageServerID: nil, using: transaction)
|
||||||
|
guard let visibleMessage = message as? VisibleMessage else {
|
||||||
|
return self.handleFailure(for: notificationContent)
|
||||||
}
|
}
|
||||||
)
|
let tsIncomingMessageID = try MessageReceiver.handleVisibleMessage(visibleMessage, associatedWithProto: proto, openGroupID: nil, using: transaction)
|
||||||
*/
|
guard let tsIncomingMessage = TSIncomingMessage.fetch(uniqueId: tsIncomingMessageID, transaction: transaction) else {
|
||||||
} else {
|
return self.handleFailure(for: notificationContent)
|
||||||
self.completeWithFailure(content: notificationContent)
|
|
||||||
}
|
}
|
||||||
}
|
let snippet = tsIncomingMessage.previewText(with: transaction).filterForDisplay
|
||||||
}
|
let userInfo: [String:Any] = [ NotificationServiceExtension.threadIdKey : tsIncomingMessage.thread.uniqueId!, NotificationServiceExtension.isFromRemoteKey : true ]
|
||||||
}
|
let senderPublicKey = message.sender!
|
||||||
|
let senderDisplayName = OWSProfileManager.shared().profileNameForRecipient(withID: senderPublicKey, avoidWriteTransaction: true) ?? senderPublicKey
|
||||||
/*
|
|
||||||
func handleDecryptionResult(result: OWSMessageDecryptResult, notificationContent: UNMutableNotificationContent, transaction: YapDatabaseReadWriteTransaction) {
|
|
||||||
let contentProto = try? SNProtoContent.parseData(result.plaintextData!)
|
|
||||||
var thread: TSThread
|
|
||||||
var newNotificationBody = ""
|
|
||||||
let masterPublicKey = OWSPrimaryStorage.shared().getMasterHexEncodedPublicKey(for: result.source, in: transaction) ?? result.source
|
|
||||||
var displayName = OWSUserProfile.fetch(uniqueId: masterPublicKey, transaction: transaction)?.profileName ?? SSKEnvironment.shared.contactsManager.displayName(forPhoneIdentifier: masterPublicKey)
|
|
||||||
if let groupID = contentProto?.dataMessage?.group?.id {
|
|
||||||
thread = TSGroupThread.getOrCreateThread(withGroupId: groupID, groupType: .closedGroup, transaction: transaction)
|
|
||||||
var groupName = thread.name()
|
|
||||||
if groupName.count < 1 {
|
|
||||||
groupName = MessageStrings.newGroupDefaultTitle
|
|
||||||
}
|
|
||||||
let senderName = OWSUserProfile.fetch(uniqueId: masterPublicKey, transaction: transaction)?.profileName ?? SSKEnvironment.shared.contactsManager.displayName(forPhoneIdentifier: masterPublicKey)
|
|
||||||
displayName = String(format: NotificationStrings.incomingGroupMessageTitleFormat, senderName, groupName)
|
|
||||||
let group: SNProtoGroupContext = contentProto!.dataMessage!.group!
|
|
||||||
let oldGroupModel = (thread as! TSGroupThread).groupModel
|
|
||||||
let removedMembers = NSMutableSet(array: oldGroupModel.groupMemberIds)
|
|
||||||
let newGroupModel = TSGroupModel.init(title: group.name,
|
|
||||||
memberIds:group.members,
|
|
||||||
image: oldGroupModel.groupImage,
|
|
||||||
groupId: group.id,
|
|
||||||
groupType: oldGroupModel.groupType,
|
|
||||||
adminIds: group.admins)
|
|
||||||
removedMembers.minus(Set(newGroupModel.groupMemberIds))
|
|
||||||
newGroupModel.removedMembers = removedMembers
|
|
||||||
switch contentProto?.dataMessage?.group?.type {
|
|
||||||
case .update:
|
|
||||||
newNotificationBody = oldGroupModel.getInfoStringAboutUpdate(to: newGroupModel, contactsManager: SSKEnvironment.shared.contactsManager)
|
|
||||||
break
|
|
||||||
case .quit:
|
|
||||||
let nameString = SSKEnvironment.shared.contactsManager.displayName(forPhoneIdentifier: masterPublicKey, transaction: transaction)
|
|
||||||
newNotificationBody = NSLocalizedString("GROUP_MEMBER_LEFT", comment: nameString)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
thread = TSContactThread.getOrCreateThread(withContactId: result.source, transaction: transaction)
|
|
||||||
}
|
|
||||||
let userInfo: [String:Any] = [ NotificationServiceExtension.threadIdKey : thread.uniqueId!, NotificationServiceExtension.isFromRemoteKey : true ]
|
|
||||||
notificationContent.title = displayName
|
|
||||||
notificationContent.userInfo = userInfo
|
notificationContent.userInfo = userInfo
|
||||||
notificationContent.badge = 1
|
notificationContent.badge = 1
|
||||||
if let attachment = contentProto?.dataMessage?.attachments.last {
|
let notificationsPreference = Environment.shared.preferences!.notificationPreviewType()
|
||||||
newNotificationBody = TSAttachment.emoji(forMimeType: attachment.contentType!) + "Attachment"
|
switch notificationsPreference {
|
||||||
if let rawMessageBody = contentProto?.dataMessage?.body, rawMessageBody.count > 0 {
|
case .namePreview:
|
||||||
newNotificationBody += ": \(rawMessageBody)"
|
notificationContent.title = senderDisplayName
|
||||||
}
|
notificationContent.body = snippet!
|
||||||
}
|
|
||||||
if newNotificationBody.count < 1 {
|
|
||||||
newNotificationBody = contentProto?.dataMessage?.body ?? "You've got a new message"
|
|
||||||
}
|
|
||||||
newNotificationBody = handleMentionIfNecessary(rawMessageBody: newNotificationBody, threadID: thread.uniqueId!, transaction: transaction)
|
|
||||||
|
|
||||||
let notificationPreference = Environment.shared.preferences
|
|
||||||
if let notificationType = notificationPreference?.notificationPreviewType() {
|
|
||||||
switch notificationType {
|
|
||||||
case .nameNoPreview:
|
case .nameNoPreview:
|
||||||
|
notificationContent.title = senderDisplayName
|
||||||
notificationContent.body = "New Message"
|
notificationContent.body = "New Message"
|
||||||
case .noNameNoPreview:
|
case .noNameNoPreview:
|
||||||
notificationContent.title = ""
|
notificationContent.title = "Session"
|
||||||
notificationContent.body = "New Message"
|
notificationContent.body = "New Message"
|
||||||
default:
|
default: break
|
||||||
notificationContent.body = newNotificationBody
|
|
||||||
}
|
}
|
||||||
} else {
|
self.handleSuccess(for: notificationContent)
|
||||||
notificationContent.body = newNotificationBody
|
} catch {
|
||||||
}
|
self.handleFailure(for: notificationContent)
|
||||||
|
|
||||||
if notificationContent.body.count < 1 {
|
|
||||||
self.completeWithFailure(content: notificationContent)
|
|
||||||
} else {
|
|
||||||
self.contentHandler!(notificationContent)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
func handleMentionIfNecessary(rawMessageBody: String, threadID: String, transaction: YapDatabaseReadWriteTransaction) -> String {
|
|
||||||
var string = rawMessageBody
|
|
||||||
let regex = try! NSRegularExpression(pattern: "@[0-9a-fA-F]*", options: [])
|
|
||||||
var outerMatch = regex.firstMatch(in: string, options: .withoutAnchoringBounds, range: NSRange(location: 0, length: string.utf16.count))
|
|
||||||
while let match = outerMatch {
|
|
||||||
let publicKey = String((string as NSString).substring(with: match.range).dropFirst()) // Drop the @
|
|
||||||
let matchEnd: Int
|
|
||||||
let displayName: String? = OWSProfileManager.shared().profileNameForRecipient(withID: publicKey, transaction: transaction)
|
|
||||||
if let displayName = displayName {
|
|
||||||
string = (string as NSString).replacingCharacters(in: match.range, with: "@\(displayName)")
|
|
||||||
matchEnd = match.range.location + displayName.utf16.count
|
|
||||||
} else {
|
|
||||||
matchEnd = match.range.location + match.range.length
|
|
||||||
}
|
}
|
||||||
outerMatch = regex.firstMatch(in: string, options: .withoutAnchoringBounds, range: NSRange(location: matchEnd, length: string.utf16.count - matchEnd))
|
|
||||||
}
|
|
||||||
return string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setUpIfNecessary(completion: @escaping () -> Void) {
|
func setUpIfNecessary(completion: @escaping () -> Void) {
|
||||||
|
@ -193,22 +110,19 @@ final class NotificationServiceExtension : UNNotificationServiceExtension {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self,
|
NotificationCenter.default.addObserver(self, selector: #selector(storageIsReady), name: .StorageIsReady, object: nil)
|
||||||
selector: #selector(storageIsReady),
|
|
||||||
name: .StorageIsReady,
|
|
||||||
object: nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func serviceExtensionTimeWillExpire() {
|
override func serviceExtensionTimeWillExpire() {
|
||||||
// Called just before the extension will be terminated by the system.
|
// Called just before the extension will be terminated by the system.
|
||||||
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
|
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
|
||||||
if let contentHandler = contentHandler, let notificationContent = notificationContent {
|
let userInfo: [String:Any] = [ NotificationServiceExtension.isFromRemoteKey : true ]
|
||||||
contentHandler(notificationContent)
|
let notificationContent = self.notificationContent!
|
||||||
}
|
notificationContent.userInfo = userInfo
|
||||||
}
|
notificationContent.badge = 1
|
||||||
|
notificationContent.title = "Session"
|
||||||
func wasReceivedByUD(envelope: SNProtoEnvelope) -> Bool {
|
notificationContent.body = "New Message"
|
||||||
return (envelope.type == .unidentifiedSender && (!envelope.hasSource || envelope.source!.count < 1))
|
handleSuccess(for: notificationContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
|
@ -242,14 +156,18 @@ final class NotificationServiceExtension : UNNotificationServiceExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
func completeSilenty() {
|
func completeSilenty() {
|
||||||
contentHandler?(.init())
|
contentHandler!(.init())
|
||||||
}
|
}
|
||||||
|
|
||||||
func completeWithFailure(content: UNMutableNotificationContent) {
|
func handleSuccess(for content: UNMutableNotificationContent) {
|
||||||
content.body = "You've got a new message"
|
contentHandler!(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleFailure(for content: UNMutableNotificationContent) {
|
||||||
|
content.body = "New Message"
|
||||||
content.title = "Session"
|
content.title = "Session"
|
||||||
let userInfo: [String:Any] = [ NotificationServiceExtension.isFromRemoteKey : true ]
|
let userInfo: [String:Any] = [ NotificationServiceExtension.isFromRemoteKey : true ]
|
||||||
content.userInfo = userInfo
|
content.userInfo = userInfo
|
||||||
contentHandler?(content)
|
contentHandler!(content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1282,7 +1282,7 @@
|
||||||
7BC01A3B241F40AB00BC7C55 /* SessionPushNotificationExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SessionPushNotificationExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
7BC01A3B241F40AB00BC7C55 /* SessionPushNotificationExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SessionPushNotificationExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
7BC01A3D241F40AB00BC7C55 /* NotificationServiceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationServiceExtension.swift; sourceTree = "<group>"; };
|
7BC01A3D241F40AB00BC7C55 /* NotificationServiceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationServiceExtension.swift; sourceTree = "<group>"; };
|
||||||
7BC01A3F241F40AB00BC7C55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
7BC01A3F241F40AB00BC7C55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
7BDCFC0424206E7300641C39 /* LokiPushNotificationService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LokiPushNotificationService.entitlements; sourceTree = "<group>"; };
|
7BDCFC0424206E7300641C39 /* SessionPushNotificationExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SessionPushNotificationExtension.entitlements; sourceTree = "<group>"; };
|
||||||
7BDCFC07242186E700641C39 /* NotificationServiceExtensionContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationServiceExtensionContext.swift; sourceTree = "<group>"; };
|
7BDCFC07242186E700641C39 /* NotificationServiceExtensionContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationServiceExtensionContext.swift; sourceTree = "<group>"; };
|
||||||
7DD180F770F8518B4E8796F2 /* Pods-SessionUtilitiesKit.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SessionUtilitiesKit.app store release.xcconfig"; path = "Pods/Target Support Files/Pods-SessionUtilitiesKit/Pods-SessionUtilitiesKit.app store release.xcconfig"; sourceTree = "<group>"; };
|
7DD180F770F8518B4E8796F2 /* Pods-SessionUtilitiesKit.app store release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SessionUtilitiesKit.app store release.xcconfig"; path = "Pods/Target Support Files/Pods-SessionUtilitiesKit/Pods-SessionUtilitiesKit.app store release.xcconfig"; sourceTree = "<group>"; };
|
||||||
8981C8F64D94D3C52EB67A2C /* Pods-SignalTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-SignalTests/Pods-SignalTests.test.xcconfig"; sourceTree = "<group>"; };
|
8981C8F64D94D3C52EB67A2C /* Pods-SignalTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-SignalTests/Pods-SignalTests.test.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
@ -2687,7 +2687,7 @@
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
7BC01A3F241F40AB00BC7C55 /* Info.plist */,
|
7BC01A3F241F40AB00BC7C55 /* Info.plist */,
|
||||||
7BDCFC0424206E7300641C39 /* LokiPushNotificationService.entitlements */,
|
7BDCFC0424206E7300641C39 /* SessionPushNotificationExtension.entitlements */,
|
||||||
);
|
);
|
||||||
path = Meta;
|
path = Meta;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -5748,7 +5748,7 @@
|
||||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
CODE_SIGN_ENTITLEMENTS = SessionPushNotificationExtension/Meta/LokiPushNotificationService.entitlements;
|
CODE_SIGN_ENTITLEMENTS = SessionPushNotificationExtension/Meta/SessionPushNotificationExtension.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
@ -5818,7 +5818,7 @@
|
||||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = SessionPushNotificationExtension/Meta/LokiPushNotificationService.entitlements;
|
CODE_SIGN_ENTITLEMENTS = SessionPushNotificationExtension/Meta/SessionPushNotificationExtension.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
|
Loading…
Reference in New Issue