The solution is to take the raw string from MSGMessageBody
public enum MSGMessageBody {
case text(String)
case emoji(String)
case image(UIImage)
case imageFromUrl(URL)
case video(UIImage, String)
case custom(Any)
var rawValue: Any { //<- add property to get the raw value
switch self {
case .custom(let value): return value
case .text(let value): return value
case .emoji(let value): return value
case .image(let value): return value
case .imageFromUrl(let value): return value
case .video(_, let video): return video
}
}
}
or in my current case i just added an extension
extension MSGMessageBody {
var rawValue: Any {
switch self {
case .custom(let value): return value
case .text(let value): return value
case .emoji(let value): return value
case .image(let value): return value
case .imageFromUrl(let value): return value
case .video(_, let video): return video
}
}
}
//
let rawString = message.body.rawValue
print(rawString)
Issue: Problem working with Firebase adding a message as MSGMessage object
1. The first step is to identify the string type before adding it to
MSGMessage
object.2. Insert the message object
3. Write the message in Firebase <- Not supported
MSGMessageBody
object is not supported type: https://firebase.google.com/docs/firestore/manage-data/data-typesThe solution is to take the raw string from MSGMessageBody
or in my current case i just added an extension