Only allow callback for identities that were not previously verified

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 1127553041
commit c8d547a08f

@ -36,8 +36,12 @@ class CallNotificationsAdapter: NSObject {
adaptee.presentMissedCall(call, callerName: callerName) adaptee.presentMissedCall(call, callerName: callerName)
} }
func presentRejectedCallWithIdentityChange(_ call: SignalCall, callerName: String) { public func presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: SignalCall, callerName: String) {
Logger.debug("\(TAG) in \(#function)") adaptee.presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: call, callerName: callerName)
adaptee.presentRejectedCallWithIdentityChange(call, callerName: callerName) }
public func presentMissedCallBecauseOfNewIdentity(call: SignalCall, callerName: String) {
adaptee.presentMissedCallBecauseOfNewIdentity(call: call, callerName: callerName)
} }
} }

@ -14,10 +14,10 @@ import UserNotifications
struct AppNotifications { struct AppNotifications {
enum Category { enum Category {
case missedCall, case missedCall,
rejectedCallFromUnseenIdentity missedCallFromNoLongerVerifiedIdentity
// Don't forget to update this! We use it to register categories. // Don't forget to update this! We use it to register categories.
static let allValues = [ missedCall, rejectedCallFromUnseenIdentity ] static let allValues = [ missedCall, missedCallFromNoLongerVerifiedIdentity ]
} }
enum Action { enum Action {
@ -39,9 +39,9 @@ struct AppNotifications {
intentIdentifiers: [], intentIdentifiers: [],
options: []) options: [])
case .rejectedCallFromUnseenIdentity: case .missedCallFromNoLongerVerifiedIdentity:
return UNNotificationCategory(identifier: "org.whispersystems.signal.AppNotifications.Category.rejectedCallFromUnseenIdentity", return UNNotificationCategory(identifier: "org.whispersystems.signal.AppNotifications.Category.missedCallFromNoLongerVerifiedIdentity",
actions: [ action(.confirmIdentityAndCallBack), action(.showThread) ], actions: [ action(.showThread) ],
intentIdentifiers: [], intentIdentifiers: [],
options: []) options: [])
} }
@ -118,7 +118,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
let notificationBody = { () -> String in let notificationBody = { () -> String in
switch previewType { switch previewType {
case .noNameNoPreview: case .noNameNoPreview:
return CallStrings.missedCallNotificationBody return CallStrings.missedCallNotificationBodyWithoutCallerName
case .nameNoPreview, .namePreview: case .nameNoPreview, .namePreview:
return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled() return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled()
? CallStrings.missedCallNotificationBodyWithoutCallerName ? CallStrings.missedCallNotificationBodyWithoutCallerName
@ -134,7 +134,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
center.add(request) center.add(request)
} }
func presentRejectedCallWithIdentityChange(_ call: SignalCall, callerName: String) { public func presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: SignalCall, callerName: String) {
Logger.debug("\(TAG) \(#function)") Logger.debug("\(TAG) \(#function)")
let content = UNMutableNotificationContent() let content = UNMutableNotificationContent()
@ -144,16 +144,42 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
let notificationBody = { () -> String in let notificationBody = { () -> String in
switch previewType { switch previewType {
case .noNameNoPreview: case .noNameNoPreview:
return CallStrings.rejectedCallWithIdentityChangeNotificationBody return CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName
case .nameNoPreview, .namePreview: case .nameNoPreview, .namePreview:
return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled() return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled()
? CallStrings.rejectedCallWithIdentityChangeNotificationBodyWithoutCallerName ? CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName
: String(format: CallStrings.rejectedCallWithIdentityChangeNotificationBodyWithCallerName, callerName)) : String(format: CallStrings.missedCallWithIdentityChangeNotificationBodyWithCallerName, callerName))
}}() }}()
content.body = notificationBody content.body = notificationBody
content.sound = UNNotificationSound.default() content.sound = UNNotificationSound.default()
content.categoryIdentifier = AppNotifications.category(.rejectedCallFromUnseenIdentity).identifier content.categoryIdentifier = AppNotifications.category(.missedCallFromNoLongerVerifiedIdentity).identifier
let request = UNNotificationRequest.init(identifier: call.localId.uuidString, content: content, trigger: nil)
center.add(request)
}
public func presentMissedCallBecauseOfNewIdentity(call: SignalCall, callerName: String) {
Logger.debug("\(TAG) \(#function)")
let content = UNMutableNotificationContent()
// TODO group by thread identifier
// content.threadIdentifier = threadId
let notificationBody = { () -> String in
switch previewType {
case .noNameNoPreview:
return CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName
case .nameNoPreview, .namePreview:
return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled()
? CallStrings.missedCallWithIdentityChangeNotificationBodyWithoutCallerName
: String(format: CallStrings.missedCallWithIdentityChangeNotificationBodyWithCallerName, callerName))
}}()
content.body = notificationBody
content.sound = UNNotificationSound.default()
content.categoryIdentifier = AppNotifications.category(.missedCall).identifier
let request = UNNotificationRequest.init(identifier: call.localId.uuidString, content: content, trigger: nil) let request = UNNotificationRequest.init(identifier: call.localId.uuidString, content: content, trigger: nil)

@ -111,46 +111,61 @@ NS_ASSUME_NONNULL_BEGIN
// give a little delay. // give a little delay.
uint64_t notificationDelay = 5; uint64_t notificationDelay = 5;
[contents [contents
addSection:[OWSTableSection addSection:
sectionWithTitle:[NSString stringWithFormat:@"Call Notifications (%llu second delay)", [OWSTableSection
notificationDelay] sectionWithTitle:[NSString
items:@[ stringWithFormat:@"Call Notifications (%llu second delay)", notificationDelay]
[OWSTableItem itemWithTitle:@"Missed Call" items:@[
actionBlock:^{ [OWSTableItem itemWithTitle:@"Missed Call"
SignalCall *call = [SignalCall actionBlock:^{
incomingCallWithLocalId:[NSUUID new] SignalCall *call =
remotePhoneNumber:thread.contactIdentifier [SignalCall incomingCallWithLocalId:[NSUUID new]
signalingId:0]; remotePhoneNumber:thread.contactIdentifier
signalingId:0];
dispatch_after(
dispatch_time(DISPATCH_TIME_NOW, dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)), (int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(), dispatch_get_main_queue(),
^{ ^{
[[Environment getCurrent] [[Environment getCurrent].callService.notificationsAdapter
.callService.notificationsAdapter presentMissedCall:call
presentMissedCall:call callerName:thread.name];
callerName:thread.name]; });
}); }],
}], [OWSTableItem
[OWSTableItem itemWithTitle:@"Rejected Call with New Safety Number"
itemWithTitle:@"Rejected Call with Unseen Safety Number" actionBlock:^{
actionBlock:^{ SignalCall *call = [SignalCall incomingCallWithLocalId:[NSUUID new]
SignalCall *call = remotePhoneNumber:thread.contactIdentifier
[SignalCall incomingCallWithLocalId:[NSUUID new] signalingId:0];
remotePhoneNumber:thread.contactIdentifier
signalingId:0]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, dispatch_get_main_queue(),
(int64_t)(notificationDelay * NSEC_PER_SEC)), ^{
dispatch_get_main_queue(), [[Environment getCurrent].callService.notificationsAdapter
^{ presentMissedCallBecauseOfNewIdentityWithCall:call
[[Environment getCurrent].callService.notificationsAdapter callerName:thread.name];
presentRejectedCallWithIdentityChange:call });
callerName:thread.name]; }],
}); [OWSTableItem
}], itemWithTitle:@"Rejected Call with No Longer Verified Safety Number"
]]]; actionBlock:^{
SignalCall *call = [SignalCall incomingCallWithLocalId:[NSUUID new]
remotePhoneNumber:thread.contactIdentifier
signalingId:0];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(notificationDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(),
^{
[[Environment getCurrent].callService.notificationsAdapter
presentMissedCallBecauseOfNoLongerVerifiedIdentityWithCall:call
callerName:
thread.name];
});
}],
]]];
viewController.contents = contents; viewController.contents = contents;
[viewController presentFromViewController:fromViewController]; [viewController presentFromViewController:fromViewController];

@ -34,12 +34,12 @@ class SafetyNumberConfirmationAlert: NSObject {
*/ */
public func presentIfNecessary(recipientIds: [String], confirmationText: String, completion: @escaping (Bool) -> Void) -> Bool { public func presentIfNecessary(recipientIds: [String], confirmationText: String, completion: @escaping (Bool) -> Void) -> Bool {
guard let noLongerVerifiedIdentity = noLongerVerifiedIdentity(recipientIds: recipientIds) else { guard let untrustedIdentity = untrustedIdentityForSending(recipientIds: recipientIds) else {
// No identities to confirm, no alert to present. // No identities to confirm, no alert to present.
return false return false
} }
let displayName = contactsManager.displayName(forPhoneIdentifier: noLongerVerifiedIdentity.recipientId) let displayName = contactsManager.displayName(forPhoneIdentifier: untrustedIdentity.recipientId)
let titleFormat = NSLocalizedString("CONFIRM_SENDING_TO_CHANGED_IDENTITY_TITLE_FORMAT", let titleFormat = NSLocalizedString("CONFIRM_SENDING_TO_CHANGED_IDENTITY_TITLE_FORMAT",
comment: "Action sheet title presented when a users's SN have recently changed. Embeds {{contact's name or phone number}}") comment: "Action sheet title presented when a users's SN have recently changed. Embeds {{contact's name or phone number}}")
@ -52,10 +52,10 @@ class SafetyNumberConfirmationAlert: NSObject {
let actionSheetController = UIAlertController(title: title, message:body, preferredStyle: .actionSheet) let actionSheetController = UIAlertController(title: title, message:body, preferredStyle: .actionSheet)
let confirmAction = UIAlertAction(title: confirmationText, style: .default) { _ in let confirmAction = UIAlertAction(title: confirmationText, style: .default) { _ in
Logger.info("\(self.TAG) Confirmed identity: \(noLongerVerifiedIdentity)") Logger.info("\(self.TAG) Confirmed identity: \(untrustedIdentity)")
OWSDispatch.sessionStoreQueue().async { OWSDispatch.sessionStoreQueue().async {
OWSIdentityManager.shared().setVerificationState(.default, identityKey: noLongerVerifiedIdentity.identityKey, recipientId: noLongerVerifiedIdentity.recipientId, sendSyncMessage: true) OWSIdentityManager.shared().setVerificationState(.default, identityKey: untrustedIdentity.identityKey, recipientId: untrustedIdentity.recipientId, sendSyncMessage: true)
DispatchQueue.main.async { DispatchQueue.main.async {
completion(true) completion(true)
} }
@ -64,10 +64,10 @@ class SafetyNumberConfirmationAlert: NSObject {
actionSheetController.addAction(confirmAction) actionSheetController.addAction(confirmAction)
let showSafetyNumberAction = UIAlertAction(title: NSLocalizedString("VERIFY_PRIVACY", comment: "Action sheet item"), style: .default) { _ in let showSafetyNumberAction = UIAlertAction(title: NSLocalizedString("VERIFY_PRIVACY", comment: "Action sheet item"), style: .default) { _ in
Logger.info("\(self.TAG) Opted to show Safety Number for identity: \(noLongerVerifiedIdentity)") Logger.info("\(self.TAG) Opted to show Safety Number for identity: \(untrustedIdentity)")
self.presentSafetyNumberViewController(theirIdentityKey: noLongerVerifiedIdentity.identityKey, self.presentSafetyNumberViewController(theirIdentityKey: untrustedIdentity.identityKey,
theirRecipientId: noLongerVerifiedIdentity.recipientId, theirRecipientId: untrustedIdentity.recipientId,
theirDisplayName: displayName, theirDisplayName: displayName,
completion: { completion(false) }) completion: { completion(false) })
@ -92,9 +92,9 @@ class SafetyNumberConfirmationAlert: NSObject {
UIApplication.shared.frontmostViewController?.present(fingerprintViewController, animated: true, completion: completion) UIApplication.shared.frontmostViewController?.present(fingerprintViewController, animated: true, completion: completion)
} }
private func noLongerVerifiedIdentity(recipientIds: [String]) -> OWSRecipientIdentity? { private func untrustedIdentityForSending(recipientIds: [String]) -> OWSRecipientIdentity? {
return recipientIds.flatMap { return recipientIds.flatMap {
OWSIdentityManager.shared().noLongerVerifiedIdentity(recipientId: $0) OWSIdentityManager.shared().untrustedIdentityForSending(toRecipientId: $0)
}.first }.first
} }
} }

@ -470,9 +470,21 @@ protocol CallServiceObserver: class {
let newCall = SignalCall.incomingCall(localId: UUID(), remotePhoneNumber: thread.contactIdentifier(), signalingId: callId) let newCall = SignalCall.incomingCall(localId: UUID(), remotePhoneNumber: thread.contactIdentifier(), signalingId: callId)
guard OWSIdentityManager.shared().isCurrentIdentityTrustedForSending(toRecipientId: thread.contactIdentifier()) else { let untrustedIdentity = OWSIdentityManager.shared().untrustedIdentityForSending(toRecipientId: thread.contactIdentifier())
guard untrustedIdentity == nil else {
let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier()) let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier())
self.notificationsAdapter.presentRejectedCallWithIdentityChange(newCall, callerName: callerName)
switch(untrustedIdentity!.verificationState) {
case .verified:
assertionFailure("shouldn't have missed a call due to untrusted identity if the identity is verified")
self.notificationsAdapter.presentMissedCall(newCall, callerName: callerName)
case .default:
self.notificationsAdapter.presentMissedCallBecauseOfNewIdentity(call: newCall, callerName: callerName)
case .noLongerVerified:
self.notificationsAdapter.presentMissedCallBecauseOfNoLongerVerifiedIdentity(call: newCall, callerName: callerName)
}
return return
} }

@ -4,6 +4,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class OWSRecipientIdentity;
@class SignalCall; @class SignalCall;
@protocol OWSCallNotificationsAdaptee <NSObject> @protocol OWSCallNotificationsAdaptee <NSObject>
@ -12,10 +13,13 @@ NS_ASSUME_NONNULL_BEGIN
- (void)presentMissedCall:(SignalCall *)call callerName:(NSString *)callerName; - (void)presentMissedCall:(SignalCall *)call callerName:(NSString *)callerName;
- (void)presentRejectedCallWithIdentityChange:(SignalCall *)call - (void)presentMissedCallBecauseOfNewIdentity:(SignalCall *)call
callerName:(NSString *)callerName callerName:(NSString *)callerName
NS_SWIFT_NAME(presentRejectedCallWithIdentityChange(_:callerName NS_SWIFT_NAME(presentMissedCallBecauseOfNewIdentity(call:callerName:));
:));
- (void)presentMissedCallBecauseOfNoLongerVerifiedIdentity:(SignalCall *)call
callerName:(NSString *)callerName
NS_SWIFT_NAME(presentMissedCallBecauseOfNoLongerVerifiedIdentity(call:callerName:));
@end @end

@ -96,7 +96,7 @@
NSString *alertMessage; NSString *alertMessage;
switch (self.notificationPreviewType) { switch (self.notificationPreviewType) {
case NotificationNoNameNoPreview: { case NotificationNoNameNoPreview: {
alertMessage = [CallStrings missedCallNotificationBody]; alertMessage = [CallStrings missedCallNotificationBodyWithoutCallerName];
break; break;
} }
case NotificationNameNoPreview: case NotificationNameNoPreview:
@ -113,13 +113,52 @@
[self presentNotification:notification identifier:localCallId]; [self presentNotification:notification identifier:localCallId];
} }
- (void)presentRejectedCallWithIdentityChange:(SignalCall *)call callerName:(NSString *)callerName
- (void)presentMissedCallBecauseOfNewIdentity:(SignalCall *)call callerName:(NSString *)callerName
{
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber];
OWSAssert(thread != nil);
UILocalNotification *notification = [UILocalNotification new];
// Use category which allows call back
notification.category = PushManagerCategoriesMissedCall;
NSString *localCallId = call.localId.UUIDString;
notification.userInfo = @{
PushManagerUserInfoKeysLocalCallId : localCallId,
PushManagerUserInfoKeysCallBackSignalRecipientId : call.remotePhoneNumber,
Signal_Thread_UserInfo_Key : thread.uniqueId
};
NSString *alertMessage;
switch (self.notificationPreviewType) {
case NotificationNoNameNoPreview: {
alertMessage = [CallStrings missedCallWithIdentityChangeNotificationBodyWithoutCallerName];
break;
}
case NotificationNameNoPreview:
case NotificationNamePreview: {
alertMessage = (([UIDevice currentDevice].supportsCallKit &&
[[Environment getCurrent].preferences isCallKitPrivacyEnabled])
? [CallStrings missedCallWithIdentityChangeNotificationBodyWithoutCallerName]
: [NSString
stringWithFormat:[CallStrings missedCallWithIdentityChangeNotificationBodyWithCallerName],
callerName]);
break;
}
}
notification.alertBody = [NSString stringWithFormat:@"☎️ %@", alertMessage];
[self presentNotification:notification identifier:localCallId];
}
- (void)presentMissedCallBecauseOfNoLongerVerifiedIdentity:(SignalCall *)call callerName:(NSString *)callerName
{ {
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber]; TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber];
OWSAssert(thread != nil); OWSAssert(thread != nil);
UILocalNotification *notification = [UILocalNotification new]; UILocalNotification *notification = [UILocalNotification new];
notification.category = PushManagerCategoriesRejectedCallFromIdentityChange; // Use category which does not allow call back
notification.category = PushManagerCategoriesMissedCallFromNoLongerVerifiedIdentity;
NSString *localCallId = call.localId.UUIDString; NSString *localCallId = call.localId.UUIDString;
notification.userInfo = @{ notification.userInfo = @{
PushManagerUserInfoKeysLocalCallId : localCallId, PushManagerUserInfoKeysLocalCallId : localCallId,
@ -130,16 +169,16 @@
NSString *alertMessage; NSString *alertMessage;
switch (self.notificationPreviewType) { switch (self.notificationPreviewType) {
case NotificationNoNameNoPreview: { case NotificationNoNameNoPreview: {
alertMessage = [CallStrings rejectedCallWithIdentityChangeNotificationBody]; alertMessage = [CallStrings missedCallWithIdentityChangeNotificationBodyWithoutCallerName];
break; break;
} }
case NotificationNameNoPreview: case NotificationNameNoPreview:
case NotificationNamePreview: { case NotificationNamePreview: {
alertMessage = (([UIDevice currentDevice].supportsCallKit && alertMessage = (([UIDevice currentDevice].supportsCallKit &&
[[Environment getCurrent].preferences isCallKitPrivacyEnabled]) [[Environment getCurrent].preferences isCallKitPrivacyEnabled])
? [CallStrings rejectedCallWithIdentityChangeNotificationBodyWithoutCallerName] ? [CallStrings missedCallWithIdentityChangeNotificationBodyWithoutCallerName]
: [NSString : [NSString
stringWithFormat:[CallStrings rejectedCallWithIdentityChangeNotificationBodyWithCallerName], stringWithFormat:[CallStrings missedCallWithIdentityChangeNotificationBodyWithCallerName],
callerName]); callerName]);
break; break;
} }

@ -22,12 +22,11 @@ extern NSString *const Signal_Message_MarkAsRead_Identifier;
extern NSString *const PushManagerCategoriesIncomingCall; extern NSString *const PushManagerCategoriesIncomingCall;
extern NSString *const PushManagerCategoriesMissedCall; extern NSString *const PushManagerCategoriesMissedCall;
extern NSString *const PushManagerCategoriesRejectedCallFromIdentityChange; extern NSString *const PushManagerCategoriesMissedCallFromNoLongerVerifiedIdentity;
extern NSString *const PushManagerActionsAcceptCall; extern NSString *const PushManagerActionsAcceptCall;
extern NSString *const PushManagerActionsDeclineCall; extern NSString *const PushManagerActionsDeclineCall;
extern NSString *const PushManagerActionsCallBack; extern NSString *const PushManagerActionsCallBack;
extern NSString *const PushManagerActionsIgnoreIdentityChangeAndCallBack;
extern NSString *const PushManagerActionsShowThread; extern NSString *const PushManagerActionsShowThread;
extern NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId; extern NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId;

@ -209,25 +209,6 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
[self.callUIAdapter startAndShowOutgoingCallWithRecipientId:recipientId]; [self.callUIAdapter startAndShowOutgoingCallWithRecipientId:recipientId];
completionHandler(); completionHandler();
} else if ([identifier isEqualToString:PushManagerActionsIgnoreIdentityChangeAndCallBack]) {
NSString *recipientId = notification.userInfo[PushManagerUserInfoKeysCallBackSignalRecipientId];
if (!recipientId) {
DDLogError(@"%@ missing call back id", self.tag);
return;
}
NSData *currentIdentityKey = [[OWSIdentityManager sharedManager] identityKeyForRecipientId:recipientId];
if (currentIdentityKey.length <= 0) {
OWSFail(@"%@ currentIdentityKey unexpectedly empty for recipient: %@", self.tag, recipientId);
completionHandler();
return;
}
[[OWSIdentityManager sharedManager] setVerificationState:OWSVerificationStateDefault
identityKey:currentIdentityKey
recipientId:recipientId
sendSyncMessage:YES];
[self.callUIAdapter startAndShowOutgoingCallWithRecipientId:recipientId];
completionHandler();
} else if ([identifier isEqualToString:PushManagerActionsShowThread]) { } else if ([identifier isEqualToString:PushManagerActionsShowThread]) {
NSString *threadId = notification.userInfo[Signal_Thread_UserInfo_Key]; NSString *threadId = notification.userInfo[Signal_Thread_UserInfo_Key];
[Environment messageThreadId:threadId]; [Environment messageThreadId:threadId];
@ -364,8 +345,8 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
NSString *const PushManagerCategoriesIncomingCall = @"PushManagerCategoriesIncomingCall"; NSString *const PushManagerCategoriesIncomingCall = @"PushManagerCategoriesIncomingCall";
NSString *const PushManagerCategoriesMissedCall = @"PushManagerCategoriesMissedCall"; NSString *const PushManagerCategoriesMissedCall = @"PushManagerCategoriesMissedCall";
NSString *const PushManagerCategoriesRejectedCallFromIdentityChange = NSString *const PushManagerCategoriesMissedCallFromNoLongerVerifiedIdentity =
@"PushManagerCategoriesRejectedCallFromIdentityChange"; @"PushManagerCategoriesMissedCallFromNoLongerVerifiedIdentity";
NSString *const PushManagerActionsAcceptCall = @"PushManagerActionsAcceptCall"; NSString *const PushManagerActionsAcceptCall = @"PushManagerActionsAcceptCall";
NSString *const PushManagerActionsDeclineCall = @"PushManagerActionsDeclineCall"; NSString *const PushManagerActionsDeclineCall = @"PushManagerActionsDeclineCall";
@ -418,14 +399,8 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager
return missedCallCategory; return missedCallCategory;
} }
- (UIUserNotificationCategory *)signalRejectedCallWithUnseenIdentityChangeCategory - (UIUserNotificationCategory *)signalMissedCallWithNoLongerVerifiedIdentityChangeCategory
{ {
UIMutableUserNotificationAction *confirmAndCallBackAction = [UIMutableUserNotificationAction new];
confirmAndCallBackAction.identifier = PushManagerActionsIgnoreIdentityChangeAndCallBack;
confirmAndCallBackAction.title = [CallStrings confirmIdentityAndCallBackButtonTitle];
confirmAndCallBackAction.activationMode = UIUserNotificationActivationModeForeground;
confirmAndCallBackAction.destructive = NO;
confirmAndCallBackAction.authenticationRequired = YES;
UIMutableUserNotificationAction *showThreadAction = [UIMutableUserNotificationAction new]; UIMutableUserNotificationAction *showThreadAction = [UIMutableUserNotificationAction new];
showThreadAction.identifier = PushManagerActionsShowThread; showThreadAction.identifier = PushManagerActionsShowThread;
@ -435,11 +410,9 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager
showThreadAction.authenticationRequired = YES; showThreadAction.authenticationRequired = YES;
UIMutableUserNotificationCategory *rejectedCallCategory = [UIMutableUserNotificationCategory new]; UIMutableUserNotificationCategory *rejectedCallCategory = [UIMutableUserNotificationCategory new];
rejectedCallCategory.identifier = PushManagerCategoriesRejectedCallFromIdentityChange; rejectedCallCategory.identifier = PushManagerCategoriesMissedCallFromNoLongerVerifiedIdentity;
[rejectedCallCategory setActions:@[ confirmAndCallBackAction, showThreadAction ] [rejectedCallCategory setActions:@[ showThreadAction ] forContext:UIUserNotificationActionContextMinimal];
forContext:UIUserNotificationActionContextMinimal]; [rejectedCallCategory setActions:@[ showThreadAction ] forContext:UIUserNotificationActionContextDefault];
[rejectedCallCategory setActions:@[ confirmAndCallBackAction, showThreadAction ]
forContext:UIUserNotificationActionContextDefault];
return rejectedCallCategory; return rejectedCallCategory;
} }
@ -460,13 +433,13 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager
- (void)validateUserNotificationSettings - (void)validateUserNotificationSettings
{ {
UIUserNotificationSettings *settings = UIUserNotificationSettings *settings = [UIUserNotificationSettings
[UIUserNotificationSettings settingsForTypes:(UIUserNotificationType)[self allNotificationTypes] settingsForTypes:(UIUserNotificationType)[self allNotificationTypes]
categories:[NSSet setWithObjects:[self fullNewMessageNotificationCategory], categories:[NSSet setWithObjects:[self fullNewMessageNotificationCategory],
[self signalIncomingCallCategory], [self signalIncomingCallCategory],
[self signalMissedCallCategory], [self signalMissedCallCategory],
[self signalRejectedCallWithUnseenIdentityChangeCategory], [self signalMissedCallWithNoLongerVerifiedIdentityChangeCategory],
nil]]; nil]];
[UIApplication.sharedApplication registerUserNotificationSettings:settings]; [UIApplication.sharedApplication registerUserNotificationSettings:settings];
} }

@ -743,7 +743,7 @@
"MISSED_CALL" = "Missed call"; "MISSED_CALL" = "Missed call";
/* notification title. Embeds {{caller's name or phone number}} */ /* notification title. Embeds {{caller's name or phone number}} */
"MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITH_CALLER_NAME" = "Missed call because the caller's safety number changed."; "MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITH_CALLER_NAME" = "Missed call from %@ because their safety number changed.";
/* notification title */ /* notification title */
"MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITHOUT_CALLER_NAME" = "Missed call because the caller's safety number changed."; "MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITHOUT_CALLER_NAME" = "Missed call because the caller's safety number changed.";

Loading…
Cancel
Save