Changeset View
Changeset View
Standalone View
Standalone View
native/ios/NotificationService/NotificationService.mm
Show All 11 Lines | |||||
NSString *const backgroundNotificationTypeKey = @"backgroundNotifType"; | NSString *const backgroundNotificationTypeKey = @"backgroundNotifType"; | ||||
NSString *const messageInfosKey = @"messageInfos"; | NSString *const messageInfosKey = @"messageInfos"; | ||||
NSString *const encryptedPayloadKey = @"encryptedPayload"; | NSString *const encryptedPayloadKey = @"encryptedPayload"; | ||||
NSString *const encryptionFailureKey = @"encryptionFailure"; | NSString *const encryptionFailureKey = @"encryptionFailure"; | ||||
NSString *const collapseIDKey = @"collapseID"; | NSString *const collapseIDKey = @"collapseID"; | ||||
NSString *const keyserverIDKey = @"keyserverID"; | NSString *const keyserverIDKey = @"keyserverID"; | ||||
NSString *const blobHashKey = @"blobHash"; | NSString *const blobHashKey = @"blobHash"; | ||||
NSString *const blobHolderKey = @"blobHolder"; | |||||
NSString *const encryptionKeyLabel = @"encryptionKey"; | NSString *const encryptionKeyLabel = @"encryptionKey"; | ||||
// Those and future MMKV-related constants should match | // Those and future MMKV-related constants should match | ||||
// similar constants in CommNotificationsHandler.java | // similar constants in CommNotificationsHandler.java | ||||
const std::string mmkvKeySeparator = "."; | const std::string mmkvKeySeparator = "."; | ||||
const std::string mmkvKeyserverPrefix = "KEYSERVER"; | const std::string mmkvKeyserverPrefix = "KEYSERVER"; | ||||
const std::string mmkvUnreadCountSuffix = "UNREAD_COUNT"; | const std::string mmkvUnreadCountSuffix = "UNREAD_COUNT"; | ||||
▲ Show 20 Lines • Show All 520 Lines • ▼ Show 20 Lines | comm::Logger::log( | ||||
std::string([fetchError.localizedDescription UTF8String])); | std::string([fetchError.localizedDescription UTF8String])); | ||||
return; | return; | ||||
} | } | ||||
NSDictionary *largePayload = | NSDictionary *largePayload = | ||||
[NotificationService aesDecryptAndParse:largePayloadBinary | [NotificationService aesDecryptAndParse:largePayloadBinary | ||||
withKey:encryptionKey]; | withKey:encryptionKey]; | ||||
[self persistMessagePayload:largePayload]; | [self persistMessagePayload:largePayload]; | ||||
[CommIOSBlobClient.sharedInstance | |||||
storeBlobForDeletionWithHash:blobHash | |||||
andHolder:content.userInfo[blobHolderKey]]; | |||||
} | } | ||||
- (BOOL)needsSilentBadgeUpdate:(NSDictionary *)payload { | - (BOOL)needsSilentBadgeUpdate:(NSDictionary *)payload { | ||||
// TODO: refactor this check by introducing | // TODO: refactor this check by introducing | ||||
// badgeOnly property in iOS notification payload | // badgeOnly property in iOS notification payload | ||||
if (!payload[@"threadID"]) { | if (!payload[@"threadID"]) { | ||||
// This notif only contains a badge update. We could let it go through | // This notif only contains a badge update. We could let it go through | ||||
// normally, but for internal builds we set the BODY to "ENCRYPTED" for | // normally, but for internal builds we set the BODY to "ENCRYPTED" for | ||||
// debugging purposes. So instead of letting the badge-only notif go | // debugging purposes. So instead of letting the badge-only notif go | ||||
// through, we construct another notif that doesn't have a body. | // through, we construct another notif that doesn't have a body. | ||||
return true; | return true; | ||||
} | } | ||||
// If the notif is a rescind, then we'll filter it out. So we need another | // If the notif is a rescind, then we'll filter it out. So we need another | ||||
// notif to update the badge count. | // notif to update the badge count. | ||||
return [self isRescind:payload]; | return [self isRescind:payload]; | ||||
} | } | ||||
- (BOOL)isCollapsible:(NSDictionary *)payload { | - (BOOL)isCollapsible:(NSDictionary *)payload { | ||||
return payload[collapseIDKey]; | return payload[collapseIDKey]; | ||||
} | } | ||||
- (BOOL)isLargeNotification:(NSDictionary *)payload { | - (BOOL)isLargeNotification:(NSDictionary *)payload { | ||||
return payload[blobHashKey] && payload[encryptionKeyLabel]; | return payload[blobHashKey] && payload[encryptionKeyLabel] && | ||||
payload[blobHolderKey]; | |||||
} | } | ||||
- (UNNotificationContent *)getBadgeOnlyContentFor: | - (UNNotificationContent *)getBadgeOnlyContentFor: | ||||
(UNNotificationContent *)content { | (UNNotificationContent *)content { | ||||
UNMutableNotificationContent *badgeOnlyContent = | UNMutableNotificationContent *badgeOnlyContent = | ||||
[[UNMutableNotificationContent alloc] init]; | [[UNMutableNotificationContent alloc] init]; | ||||
badgeOnlyContent.badge = content.badge; | badgeOnlyContent.badge = content.badge; | ||||
return badgeOnlyContent; | return badgeOnlyContent; | ||||
▲ Show 20 Lines • Show All 328 Lines • Show Last 20 Lines |