|
|
@ -206,10 +206,10 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
|
|
|
|
#pragma mark - Signal Messages
|
|
|
|
#pragma mark - Signal Messages
|
|
|
|
|
|
|
|
|
|
|
|
- (void)notifyUserForErrorMessage:(TSErrorMessage *)message inThread:(TSThread *)thread {
|
|
|
|
- (void)notifyUserForErrorMessage:(TSErrorMessage *)message inThread:(TSThread *)thread {
|
|
|
|
OWSAssert([NSThread isMainThread]);
|
|
|
|
|
|
|
|
OWSAssert(message);
|
|
|
|
OWSAssert(message);
|
|
|
|
OWSAssert(thread);
|
|
|
|
OWSAssert(thread);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
if (thread.isMuted) {
|
|
|
|
if (thread.isMuted) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -220,7 +220,7 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
|
|
|
|
|
|
|
|
|
|
|
|
if (([UIApplication sharedApplication].applicationState != UIApplicationStateActive) && messageDescription) {
|
|
|
|
if (([UIApplication sharedApplication].applicationState != UIApplicationStateActive) && messageDescription) {
|
|
|
|
UILocalNotification *notification = [[UILocalNotification alloc] init];
|
|
|
|
UILocalNotification *notification = [[UILocalNotification alloc] init];
|
|
|
|
notification.userInfo = @{Signal_Thread_UserInfo_Key : thread.uniqueId};
|
|
|
|
notification.userInfo = @{ Signal_Thread_UserInfo_Key : thread.uniqueId };
|
|
|
|
if (shouldPlaySound) {
|
|
|
|
if (shouldPlaySound) {
|
|
|
|
notification.soundName = kNotificationsManagerNewMesssageSoundName;
|
|
|
|
notification.soundName = kNotificationsManagerNewMesssageSoundName;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -245,6 +245,7 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
|
|
|
|
AudioServicesPlayAlertSound(_newMessageSound);
|
|
|
|
AudioServicesPlayAlertSound(_newMessageSound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)notifyUserForIncomingMessage:(TSIncomingMessage *)message
|
|
|
|
- (void)notifyUserForIncomingMessage:(TSIncomingMessage *)message
|
|
|
@ -255,6 +256,7 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
|
|
|
|
OWSAssert(thread);
|
|
|
|
OWSAssert(thread);
|
|
|
|
OWSAssert(contactsManager);
|
|
|
|
OWSAssert(contactsManager);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
if (thread.isMuted) {
|
|
|
|
if (thread.isMuted) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -290,8 +292,10 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
|
|
|
|
|
|
|
|
|
|
|
|
notification.category = (isNoLongerVerified ? Signal_Full_New_Message_Category_No_Longer_Verified
|
|
|
|
notification.category = (isNoLongerVerified ? Signal_Full_New_Message_Category_No_Longer_Verified
|
|
|
|
: Signal_Full_New_Message_Category);
|
|
|
|
: Signal_Full_New_Message_Category);
|
|
|
|
notification.userInfo =
|
|
|
|
notification.userInfo = @{
|
|
|
|
@{Signal_Thread_UserInfo_Key : thread.uniqueId, Signal_Message_UserInfo_Key : message.uniqueId};
|
|
|
|
Signal_Thread_UserInfo_Key : thread.uniqueId,
|
|
|
|
|
|
|
|
Signal_Message_UserInfo_Key : message.uniqueId
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if ([thread isGroupThread]) {
|
|
|
|
if ([thread isGroupThread]) {
|
|
|
|
NSString *threadName = [NSString stringWithFormat:@"\"%@\"", groupName];
|
|
|
|
NSString *threadName = [NSString stringWithFormat:@"\"%@\"", groupName];
|
|
|
@ -307,13 +311,13 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case NotificationNameNoPreview: {
|
|
|
|
case NotificationNameNoPreview: {
|
|
|
|
notification.userInfo = @{Signal_Thread_UserInfo_Key : thread.uniqueId};
|
|
|
|
notification.userInfo = @{ Signal_Thread_UserInfo_Key : thread.uniqueId };
|
|
|
|
if ([thread isGroupThread]) {
|
|
|
|
if ([thread isGroupThread]) {
|
|
|
|
notification.alertBody = [NSString
|
|
|
|
notification.alertBody = [NSString
|
|
|
|
stringWithFormat:@"%@ \"%@\"", NSLocalizedString(@"APN_MESSAGE_IN_GROUP", nil), groupName];
|
|
|
|
stringWithFormat:@"%@ \"%@\"", NSLocalizedString(@"APN_MESSAGE_IN_GROUP", nil), groupName];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
notification.alertBody =
|
|
|
|
notification.alertBody = [NSString
|
|
|
|
[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"APN_MESSAGE_FROM", nil), senderName];
|
|
|
|
stringWithFormat:@"%@ %@", NSLocalizedString(@"APN_MESSAGE_FROM", nil), senderName];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -332,6 +336,7 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
|
|
|
|
AudioServicesPlayAlertSound(_newMessageSound);
|
|
|
|
AudioServicesPlayAlertSound(_newMessageSound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)shouldPlaySoundForNotification
|
|
|
|
- (BOOL)shouldPlaySoundForNotification
|
|
|
|