自定义消息不支持转发

自定义的消息、音视频相关的消息等不支持转发
发布时间: 2021-12-01 09:48

回答:

自定义消息只支持逐条转发,不支持合并转发。

在 RCCombineMessageUtility.m 类中对转发设置了白名单,如需修改,可以集成源码(集成参考: https://doc.rongcloud.cn/im/IOS/5.X/ui/import#source ),对下面方法进行修改。

//消息合并转发的白名单
+ (BOOL)allSelectedCombineForwordMessagesAreLegal:(NSArray *)allSelectedMessages {    
    if (!allSelectedMessages) {
            return NO;   
    }    
    for (RCMessageModel *model in allSelectedMessages) {       
         if (!model) {     
                return NO;   
         }        
         //未成功发送的消息不可转发     
         if (model.sentStatus == SentStatus_SENDING || model.sentStatus == SentStatus_FAILED ||
             model.sentStatus == SentStatus_CANCELED) {      
             return NO;       
         }        
         NSArray *whiteList = @[  
           RCTextMessageTypeIdentifier,     
           @"RC:ImgTextMsg",            
           @"RC:StkMsg",            
           @"RC:CardMsg",            
           RCLocationMessageTypeIdentifier,            
           RCSightMessageTypeIdentifier,            
           RCImageMessageTypeIdentifier,            
           RCFileMessageTypeIdentifier,            
           RCCombineMessageTypeIdentifier,            
           RCHQVoiceMessageTypeIdentifier,            
           RCVoiceMessageTypeIdentifier,            
           RCGIFMessageTypeIdentifier,            
           @"RC:VCSummary"        
         ];        
         if (![whiteList containsObject:model.objectName] || model.content.destructDuration > 0) {   
             return NO;       
         }    
       }   
       return YES;
}


//消息逐条转发的白名单
+ (BOOL)allSelectedOneByOneForwordMessagesAreLegal:(NSArray *)allSelectedMessages {   
    if (!allSelectedMessages) {     
         return NO;    
    }    
    for (RCMessageModel *model in allSelectedMessages) {  
        if (!model) {    
            return NO;      
        }        
        //未成功发送的消息不可转发        
        if (model.sentStatus == SentStatus_SENDING || model.sentStatus == SentStatus_FAILED ||
            model.sentStatus == SentStatus_CANCELED) {           
            return NO;      
        }        
        NSArray *whiteList = @[            
        RCTextMessageTypeIdentifier,            
        @"RC:ImgTextMsg",            
        @"RC:StkMsg",            
        @"RC:CardMsg",            
        RCLocationMessageTypeIdentifier,            
        RCSightMessageTypeIdentifier,            
        RCImageMessageTypeIdentifier,            
        RCFileMessageTypeIdentifier,            
        RCCombineMessageTypeIdentifier,            
        RCHQVoiceMessageTypeIdentifier,            
        RCVoiceMessageTypeIdentifier,            
        RCGIFMessageTypeIdentifier,            
        RCReferenceMessageTypeIdentifier        
        ];        
        if (![whiteList containsObject:model.objectName] || model.content.destructDuration > 0) {            
        return NO;        
        }    
     }    
     return YES;
}