diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index b17bb9507..ef8ef7e23 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -136,7 +136,9 @@ static UICompositeViewDescription *compositeDescription = nil; && (strcmp(linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT, LINPHONE_DUMMY_SUBJECT) != 0 || linphone_chat_room_get_nb_participants(_chatRoom) > 1)) _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom)]; else { - const LinphoneAddress *addr = linphone_participant_get_address(linphone_chat_room_get_participants(_chatRoom)->data); + bctbx_list_t *participants = linphone_chat_room_get_participants(_chatRoom); + LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL; + const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_chatRoom); [ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr]; } @@ -501,7 +503,10 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onCallClick:(id)sender { - [LinphoneManager.instance call:linphone_participant_get_address(linphone_chat_room_get_participants(_chatRoom)->data)]; + bctbx_list_t *participants = linphone_chat_room_get_participants(_chatRoom); + LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL; + const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_chatRoom); + [LinphoneManager.instance call:addr]; } - (IBAction)onListSwipe:(id)sender { diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index afafdb147..33b79fe4a 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -672,12 +672,14 @@ didInvalidatePushTokenForType:(NSString *)type { } else if ([response.actionIdentifier isEqual:@"Reply"]) { NSString *replyText = [(UNTextInputNotificationResponse *)response userText]; - NSString *from = [response.notification.request.content.userInfo - objectForKey:@"from_addr"]; - [LinphoneManager.instance send:replyText to:from]; + NSString *chat_room_address = [response.notification.request.content.userInfo + objectForKey:@"chat_room_address"]; + NSString *from_address = [response.notification.request.content.userInfo + objectForKey:@"from_addr"]; + [LinphoneManager.instance send:replyText to:[chat_room_address isEqualToString:@""] ? from_address : chat_room_address]; } else if ([response.actionIdentifier isEqual:@"Seen"]) { NSString *from = [response.notification.request.content.userInfo - objectForKey:@"from_addr"]; + objectForKey:@"chat_room_address"]; LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, [from UTF8String]); if (room) { @@ -848,7 +850,7 @@ didInvalidatePushTokenForType:(NSString *)type { // use the standard handler [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; } else if ([identifier isEqualToString:@"mark_read"]) { - NSString *from = [notification.userInfo objectForKey:@"from_addr"]; + NSString *from = [notification.userInfo objectForKey:@"chat_room_address"]; LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, [from UTF8String]); if (room) { if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) @@ -891,8 +893,9 @@ didInvalidatePushTokenForType:(NSString *)type { } else if ([notification.category isEqualToString:@"incoming_msg"] && [identifier isEqualToString:@"reply_inline"]) { NSString *replyText = [responseInfo objectForKey:UIUserNotificationActionResponseTypedTextKey]; - NSString *from = [notification.userInfo objectForKey:@"from_addr"]; - [LinphoneManager.instance send:replyText to:from]; + NSString *chat_room_address = [notification.userInfo objectForKey:@"chat_room_address"]; + NSString *from_address = [notification.userInfo objectForKey:@"from_addr"]; + [LinphoneManager.instance send:replyText to:[chat_room_address isEqualToString:@""] ? from_address : chat_room_address]; } completionHandler(); } diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 52e96fb75..00b35def8 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1169,9 +1169,11 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } else { notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG", nil), from]; } + char *room_address = linphone_chat_room_get_conference_address(room) ? linphone_address_as_string_uri_only(linphone_chat_room_get_conference_address(room)) : NULL; + NSString *room_uri = room_address ? [NSString stringWithUTF8String:room_address] : @""; notif.alertAction = NSLocalizedString(@"Show", nil); notif.soundName = @"msg.caf"; - notif.userInfo = @{ @"from" : from, @"from_addr" : remote_uri, @"call-id" : callID }; + notif.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"call-id" : callID, @"chat_room_address" : room_uri}; notif.accessibilityLabel = @"Message notif"; [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } @@ -1210,9 +1212,11 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } else { content.body = from; } + char *room_address = linphone_chat_room_get_conference_address(room) ? linphone_address_as_string_uri_only(linphone_chat_room_get_conference_address(room)) : NULL; + NSString *room_uri = room_address ? [NSString stringWithUTF8String:room_address] : @""; content.sound = [UNNotificationSound soundNamed:@"msg.caf"]; content.categoryIdentifier = @"msg_cat"; - content.userInfo = @{ @"from" : from, @"from_addr" : remote_uri, @"CallId" : callID }; + content.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"CallId" : callID, @"chat_room_address" : room_uri}; content.accessibilityLabel = @"Message notif"; UNNotificationRequest *req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL]; diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index 683882195..0488bdba8 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -69,13 +69,12 @@ _addressLabel.text = [NSString stringWithUTF8String:subject]; [_avatarImage setImage:[UIImage imageNamed:@"chat_group_avatar.png"] bordered:NO withRoundedRadius:YES]; } else { - if (linphone_chat_room_get_participants(chatRoom) != NULL) { - LinphoneParticipant *participant = linphone_chat_room_get_participants(chatRoom)->data; - const LinphoneAddress *addr = linphone_participant_get_address(participant); - if (addr) { - [ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr]; - [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; - } + bctbx_list_t *participants = linphone_chat_room_get_participants(chatRoom); + LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL; + const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(chatRoom); + if (addr) { + [ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr]; + [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; } else { _addressLabel.text = [NSString stringWithUTF8String:LINPHONE_DUMMY_SUBJECT]; }