restore "confirm and callback" functionality

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

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

@ -134,7 +134,7 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
center.add(request) center.add(request)
} }
func presentRejectedCallWithUnseenIdentityChange(_ call: SignalCall, callerName: String) { func presentRejectedCallWithIdentityChange(_ call: SignalCall, callerName: String) {
Logger.debug("\(TAG) \(#function)") Logger.debug("\(TAG) \(#function)")
let content = UNMutableNotificationContent() let content = UNMutableNotificationContent()
@ -144,11 +144,11 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
let notificationBody = { () -> String in let notificationBody = { () -> String in
switch previewType { switch previewType {
case .noNameNoPreview: case .noNameNoPreview:
return CallStrings.rejectedCallWithUnseenIdentityChangeNotificationBody return CallStrings.rejectedCallWithIdentityChangeNotificationBody
case .nameNoPreview, .namePreview: case .nameNoPreview, .namePreview:
return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled() return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled()
? CallStrings.rejectedCallWithUnseenIdentityChangeNotificationBodyWithoutCallerName ? CallStrings.rejectedCallWithIdentityChangeNotificationBodyWithoutCallerName
: String(format: CallStrings.rejectedCallWithUnseenIdentityChangeNotificationBodyWithCallerName, callerName)) : String(format: CallStrings.rejectedCallWithIdentityChangeNotificationBodyWithCallerName, callerName))
}}() }}()
content.body = notificationBody content.body = notificationBody

@ -13,22 +13,19 @@ import Foundation
static let confirmAndCallButtonTitle = NSLocalizedString("SAFETY_NUMBER_CHANGED_CONFIRM_CALL_ACTION", comment: "alert button text to confirm placing an outgoing call after the recipients Safety Number has changed.") static let confirmAndCallButtonTitle = NSLocalizedString("SAFETY_NUMBER_CHANGED_CONFIRM_CALL_ACTION", comment: "alert button text to confirm placing an outgoing call after the recipients Safety Number has changed.")
static let callBackAlertTitle = NSLocalizedString("CALL_USER_ALERT_TITLE", comment: "Title for alert offering to call a user.")
static let callBackAlertMessageFormat = NSLocalizedString("CALL_USER_ALERT_MESSAGE_FORMAT", comment: "Message format for alert offering to call a user. Embeds {{the user's display name or phone number}}.")
static let callBackAlertCallButton = NSLocalizedString("CALL_USER_ALERT_CALL_BUTTON", comment: "Label for call button for alert offering to call a user.")
// MARK: Notification actions // MARK: Notification actions
static let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action") static let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action")
static let confirmIdentityAndCallBackButtonTitle = NSLocalizedString("CONFIRM_IDENTITY_AND_CALLBACK_BUTTON_TITLE", comment: "notification action, confirming that it's OK to proceed calling after a caller's Safety Number has changed")
static let showThreadButtonTitle = NSLocalizedString("SHOW_THREAD_BUTTON_TITLE", comment: "notification action") static let showThreadButtonTitle = NSLocalizedString("SHOW_THREAD_BUTTON_TITLE", comment: "notification action")
// MARK: Missed Call Notification // MARK: Missed Call Notification
static let missedCallNotificationBody = NSLocalizedString("MISSED_CALL", comment: "notification title") static let missedCallNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL", comment: "notification title")
static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITH_NAME", comment: "notification title. Embeds {{Caller's Name}}") static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITH_NAME", comment: "notification title. Embeds {{caller's name or phone number}}")
static let missedCallNotificationBodyWithoutCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITHOUT_NAME", comment: "notification title.")
// MARK: Missed with Unseen identity Notification // MARK: Missed with changed identity notification (for not previously verified identity)
static let rejectedCallWithUnseenIdentityChangeNotificationBody = NSLocalizedString("MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY", comment: "notification action") static let missedCallWithIdentityChangeNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITHOUT_CALLER_NAME", comment: "notification title")
static let rejectedCallWithUnseenIdentityChangeNotificationBodyWithoutCallerName = NSLocalizedString("MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY_WITHOUT_CALLER_NAME", comment: "notification action") static let missedCallWithIdentityChangeNotificationBodyWithCallerName = NSLocalizedString("MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITH_CALLER_NAME", comment: "notification title. Embeds {{caller's name or phone number}}")
static let rejectedCallWithUnseenIdentityChangeNotificationBodyWithCallerName = NSLocalizedString("MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY_WITH_CALLER_NAME", comment: "notification action")
static let callBackAlertTitle = NSLocalizedString("CALL_USER_ALERT_TITLE", comment: "Title for alert offering to call a user.")
static let callBackAlertMessageFormat = NSLocalizedString("CALL_USER_ALERT_MESSAGE_FORMAT", comment: "Message format for alert offering to call a user. Embeds {{the user's display name or phone number}}.")
static let callBackAlertCallButton = NSLocalizedString("CALL_USER_ALERT_CALL_BUTTON", comment: "Label for call button for alert offering to call a user.")
} }

@ -146,8 +146,8 @@ NS_ASSUME_NONNULL_BEGIN
dispatch_get_main_queue(), dispatch_get_main_queue(),
^{ ^{
[[Environment getCurrent].callService.notificationsAdapter [[Environment getCurrent].callService.notificationsAdapter
presentRejectedCallWithUnseenIdentityChange:call presentRejectedCallWithIdentityChange:call
callerName:thread.name]; callerName:thread.name];
}); });
}], }],
]]]; ]]];

@ -472,7 +472,7 @@ protocol CallServiceObserver: class {
guard OWSIdentityManager.shared().isCurrentIdentityTrustedForSending(toRecipientId: thread.contactIdentifier()) else { guard OWSIdentityManager.shared().isCurrentIdentityTrustedForSending(toRecipientId: thread.contactIdentifier()) else {
let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier()) let callerName = self.contactsManager.displayName(forPhoneIdentifier: thread.contactIdentifier())
self.notificationsAdapter.presentRejectedCallWithUnseenIdentityChange(newCall, callerName: callerName) self.notificationsAdapter.presentRejectedCallWithIdentityChange(newCall, callerName: callerName)
return return
} }

@ -12,9 +12,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)presentMissedCall:(SignalCall *)call callerName:(NSString *)callerName; - (void)presentMissedCall:(SignalCall *)call callerName:(NSString *)callerName;
- (void)presentRejectedCallWithUnseenIdentityChange:(SignalCall *)call - (void)presentRejectedCallWithIdentityChange:(SignalCall *)call
callerName:(NSString *)callerName callerName:(NSString *)callerName
NS_SWIFT_NAME(presentRejectedCallWithUnseenIdentityChange(_:callerName:)); NS_SWIFT_NAME(presentRejectedCallWithIdentityChange(_:callerName
:));
@end @end

@ -113,13 +113,13 @@
[self presentNotification:notification identifier:localCallId]; [self presentNotification:notification identifier:localCallId];
} }
- (void)presentRejectedCallWithUnseenIdentityChange:(SignalCall *)call callerName:(NSString *)callerName - (void)presentRejectedCallWithIdentityChange:(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 = PushManagerCategoriesRejectedCallFromUnseenIdentityChange; notification.category = PushManagerCategoriesRejectedCallFromIdentityChange;
NSString *localCallId = call.localId.UUIDString; NSString *localCallId = call.localId.UUIDString;
notification.userInfo = @{ notification.userInfo = @{
PushManagerUserInfoKeysLocalCallId : localCallId, PushManagerUserInfoKeysLocalCallId : localCallId,
@ -130,17 +130,16 @@
NSString *alertMessage; NSString *alertMessage;
switch (self.notificationPreviewType) { switch (self.notificationPreviewType) {
case NotificationNoNameNoPreview: { case NotificationNoNameNoPreview: {
alertMessage = [CallStrings rejectedCallWithUnseenIdentityChangeNotificationBody]; alertMessage = [CallStrings rejectedCallWithIdentityChangeNotificationBody];
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 rejectedCallWithUnseenIdentityChangeNotificationBodyWithoutCallerName] ? [CallStrings rejectedCallWithIdentityChangeNotificationBodyWithoutCallerName]
: [NSString : [NSString
stringWithFormat:[CallStrings stringWithFormat:[CallStrings rejectedCallWithIdentityChangeNotificationBodyWithCallerName],
rejectedCallWithUnseenIdentityChangeNotificationBodyWithCallerName],
callerName]); callerName]);
break; break;
} }

@ -22,12 +22,12 @@ 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 PushManagerCategoriesRejectedCallFromUnseenIdentityChange; extern NSString *const PushManagerCategoriesRejectedCallFromIdentityChange;
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 PushManagerActionsConfirmIdentityAndCallBack; extern NSString *const PushManagerActionsIgnoreIdentityChangeAndCallBack;
extern NSString *const PushManagerActionsShowThread; extern NSString *const PushManagerActionsShowThread;
extern NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId; extern NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId;

@ -209,13 +209,23 @@ NSString *const Signal_Message_MarkAsRead_Identifier = @"Signal_Message_MarkAsRe
[self.callUIAdapter startAndShowOutgoingCallWithRecipientId:recipientId]; [self.callUIAdapter startAndShowOutgoingCallWithRecipientId:recipientId];
completionHandler(); completionHandler();
} else if ([identifier isEqualToString:PushManagerActionsConfirmIdentityAndCallBack]) { } else if ([identifier isEqualToString:PushManagerActionsIgnoreIdentityChangeAndCallBack]) {
NSString *recipientId = notification.userInfo[PushManagerUserInfoKeysCallBackSignalRecipientId]; NSString *recipientId = notification.userInfo[PushManagerUserInfoKeysCallBackSignalRecipientId];
if (!recipientId) { if (!recipientId) {
DDLogError(@"%@ missing call back id", self.tag); DDLogError(@"%@ missing call back id", self.tag);
return; 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]; [self.callUIAdapter startAndShowOutgoingCallWithRecipientId:recipientId];
completionHandler(); completionHandler();
} else if ([identifier isEqualToString:PushManagerActionsShowThread]) { } else if ([identifier isEqualToString:PushManagerActionsShowThread]) {
@ -354,13 +364,14 @@ 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 PushManagerCategoriesRejectedCallFromUnseenIdentityChange = NSString *const PushManagerCategoriesRejectedCallFromIdentityChange =
@"PushManagerCategoriesRejectedCallFromUnseenIdentityChange"; @"PushManagerCategoriesRejectedCallFromIdentityChange";
NSString *const PushManagerActionsAcceptCall = @"PushManagerActionsAcceptCall"; NSString *const PushManagerActionsAcceptCall = @"PushManagerActionsAcceptCall";
NSString *const PushManagerActionsDeclineCall = @"PushManagerActionsDeclineCall"; NSString *const PushManagerActionsDeclineCall = @"PushManagerActionsDeclineCall";
NSString *const PushManagerActionsCallBack = @"PushManagerActionsCallBack"; NSString *const PushManagerActionsCallBack = @"PushManagerActionsCallBack";
NSString *const PushManagerActionsConfirmIdentityAndCallBack = @"PushManagerActionsConfirmIdentityAndCallBack"; NSString *const PushManagerActionsIgnoreIdentityChangeAndCallBack =
@"PushManagerActionsIgnoreIdentityChangeAndCallBack";
NSString *const PushManagerActionsShowThread = @"PushManagerActionsShowThread"; NSString *const PushManagerActionsShowThread = @"PushManagerActionsShowThread";
NSString *const PushManagerUserInfoKeysLocalCallId = @"PushManagerUserInfoKeysLocalCallId"; NSString *const PushManagerUserInfoKeysLocalCallId = @"PushManagerUserInfoKeysLocalCallId";
@ -410,7 +421,7 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager
- (UIUserNotificationCategory *)signalRejectedCallWithUnseenIdentityChangeCategory - (UIUserNotificationCategory *)signalRejectedCallWithUnseenIdentityChangeCategory
{ {
UIMutableUserNotificationAction *confirmAndCallBackAction = [UIMutableUserNotificationAction new]; UIMutableUserNotificationAction *confirmAndCallBackAction = [UIMutableUserNotificationAction new];
confirmAndCallBackAction.identifier = PushManagerActionsConfirmIdentityAndCallBack; confirmAndCallBackAction.identifier = PushManagerActionsIgnoreIdentityChangeAndCallBack;
confirmAndCallBackAction.title = [CallStrings confirmIdentityAndCallBackButtonTitle]; confirmAndCallBackAction.title = [CallStrings confirmIdentityAndCallBackButtonTitle];
confirmAndCallBackAction.activationMode = UIUserNotificationActivationModeForeground; confirmAndCallBackAction.activationMode = UIUserNotificationActivationModeForeground;
confirmAndCallBackAction.destructive = NO; confirmAndCallBackAction.destructive = NO;
@ -424,7 +435,7 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager
showThreadAction.authenticationRequired = YES; showThreadAction.authenticationRequired = YES;
UIMutableUserNotificationCategory *rejectedCallCategory = [UIMutableUserNotificationCategory new]; UIMutableUserNotificationCategory *rejectedCallCategory = [UIMutableUserNotificationCategory new];
rejectedCallCategory.identifier = PushManagerCategoriesRejectedCallFromUnseenIdentityChange; rejectedCallCategory.identifier = PushManagerCategoriesRejectedCallFromIdentityChange;
[rejectedCallCategory setActions:@[ confirmAndCallBackAction, showThreadAction ] [rejectedCallCategory setActions:@[ confirmAndCallBackAction, showThreadAction ]
forContext:UIUserNotificationActionContextMinimal]; forContext:UIUserNotificationActionContextMinimal];
[rejectedCallCategory setActions:@[ confirmAndCallBackAction, showThreadAction ] [rejectedCallCategory setActions:@[ confirmAndCallBackAction, showThreadAction ]

@ -241,9 +241,6 @@
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"CONFIRM_ACCOUNT_DESTRUCTION_TITLE" = "Are you sure you want to delete your account?"; "CONFIRM_ACCOUNT_DESTRUCTION_TITLE" = "Are you sure you want to delete your account?";
/* notification action, confirming that it's OK to proceed calling after a caller's Safety Number has changed */
"CONFIRM_IDENTITY_AND_CALLBACK_BUTTON_TITLE" = "Confirm and Call Back";
/* Alert body */ /* Alert body */
"CONFIRM_LEAVE_GROUP_DESCRIPTION" = "You will no longer be able to send or receive messages in this group."; "CONFIRM_LEAVE_GROUP_DESCRIPTION" = "You will no longer be able to send or receive messages in this group.";
@ -745,14 +742,11 @@
/* notification title */ /* notification title */
"MISSED_CALL" = "Missed call"; "MISSED_CALL" = "Missed call";
/* notification action */ /* notification title. Embeds {{caller's name or phone number}} */
"MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY" = "Missed call because the caller's safety number changed."; "MISSED_CALL_WITH_CHANGED_IDENTITY_BODY_WITH_CALLER_NAME" = "Missed call because the caller's safety number changed.";
/* notification action */
"MISSED_CALL_WITH_UNSEEN_IDENTITY_BODY_WITH_CALLER_NAME" = "Missed call from %@ because their safety number changed.";
/* notification action */ /* notification title */
"MISSED_CALL_WITH_UNSEEN_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.";
/* Alert body /* Alert body
Alert body when camera is not authorized */ Alert body when camera is not authorized */
@ -762,12 +756,9 @@
Alert title when camera is not authorized */ Alert title when camera is not authorized */
"MISSING_CAMERA_PERMISSION_TITLE" = "Signal needs to access your camera."; "MISSING_CAMERA_PERMISSION_TITLE" = "Signal needs to access your camera.";
/* notification title. Embeds {{Caller's Name}} */ /* notification title. Embeds {{caller's name or phone number}} */
"MSGVIEW_MISSED_CALL_WITH_NAME" = "Missed call from %@."; "MSGVIEW_MISSED_CALL_WITH_NAME" = "Missed call from %@.";
/* notification title. */
"MSGVIEW_MISSED_CALL_WITHOUT_NAME" = "Missed call from Signal User.";
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"MSGVIEW_RECEIVED_CALL" = "You received a call from %@."; "MSGVIEW_RECEIVED_CALL" = "You received a call from %@.";
@ -1075,7 +1066,7 @@
/* button title to confirm adding a recipient to a group when their safety number has recently changed */ /* button title to confirm adding a recipient to a group when their safety number has recently changed */
"SAFETY_NUMBER_CHANGED_CONFIRM_ADD_TO_GROUP_ACTION" = "Add to Group Anyway"; "SAFETY_NUMBER_CHANGED_CONFIRM_ADD_TO_GROUP_ACTION" = "Add to Group Anyway";
/* button title to confirm calling a recipient whose safety number recently changed */ /* alert button text to confirm placing an outgoing call after the recipients Safety Number has changed. */
"SAFETY_NUMBER_CHANGED_CONFIRM_CALL_ACTION" = "Call Anyway"; "SAFETY_NUMBER_CHANGED_CONFIRM_CALL_ACTION" = "Call Anyway";
/* button title to confirm sending to a recipient whose safety number recently changed */ /* button title to confirm sending to a recipient whose safety number recently changed */

Loading…
Cancel
Save