41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Swift
		
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Swift
		
	
	
	
| //
 | |
| //  IMMessageMaker.swift
 | |
| //  Crush
 | |
| //
 | |
| //  Created by Leon on 2025/8/18.
 | |
| //
 | |
| 
 | |
| import UIKit
 | |
| import NIMSDK
 | |
| 
 | |
| /// NIMMessage maker
 | |
| class IMMessageMaker {
 | |
|     
 | |
|     static func msgWithText(_ text: String) -> V2NIMMessage {
 | |
|         let textMessage = V2NIMMessageCreator.createTextMessage(text)
 | |
|         return textMessage
 | |
|     }
 | |
|     
 | |
|     static func msgWithTips(_ text: String) -> V2NIMMessage {
 | |
|         let tipMessage = V2NIMMessageCreator.createTipsMessage(text)
 | |
|         return tipMessage
 | |
|     }
 | |
|     
 | |
|     static func msgWithCustom(_ text: String?, attachMent: String?) -> V2NIMMessage {
 | |
|         let msg = V2NIMMessageCreator.createCustomMessage(text ?? "", rawAttachment: attachMent ?? "")
 | |
|         return msg
 | |
|     }
 | |
|     
 | |
|     static func msgWithCustom(_ text: String? = "", attachment: IMCustomAttachment?) -> V2NIMMessage {
 | |
|         
 | |
|         guard let attach = attachment, let jsonString = CodableHelper.encodeToJSONString(attach) else{
 | |
|             assert(false)
 | |
|             return V2NIMMessage()
 | |
|         }
 | |
|         
 | |
|         let msg = V2NIMMessageCreator.createCustomMessage(text ?? "", rawAttachment: jsonString)
 | |
|     
 | |
|         return msg
 | |
|     }
 | |
| }
 |