twilio / conversations-ios

SPM releases

Home Page:https://www.twilio.com/docs/conversations/ios/changelog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Media-typed messages created with TwilioChatSDK return an empty THMedia array with TwilioConversationsSDK

angi-betancourt opened this issue · comments

Hi!

We are currently migrating our solutions (Web, Android and iOS) from Twilio Chat to Twilio Conversations. For the iOS part, I'm having some issues with messages and media.

I am currently using Twilio Conversations iOS SDK (2.1.0)
image
image

The issue I'm facing is that messages created before the migration (with Twilio Chat) that are media typed (message.messageType == .media) return with an empty THMedia array on them (message.attachedMedia.count == 0). Instead of having the media as an element of that array, the message have all the information on deprecated properties (mediaSid, mediaType, mediaFilename, mediaSize). For example, here in the following screenshot I am using Twilio Conversations to obtain channels and messages. We can see a message that was created with Twilio Chat. The message was created as type=media and has an image… but the media array of the message has 0 elements. Instead of returning the media as an element of the array, the message has that data on the deprecated properties.
image

If it helps in any way, here is a screenshot with a quick console debug prints to show the difference between messages with media created with Twilio Chat and the ones with Twilio Conversations:
image

If we use Twilio Conversation API directly to see the messages, they return with the media as an element of the array.
image
Could it be that the mapping inside Twilio Conversation SDK has something?

The channel from the example I’m providing was created with Twilio Chat, the first messages were sent with Twilio Chat and the last 2 were sent with Twilio Conversation.

So far the only with this problem is the iOS SDK. Android and Web apparently does not have this issue. Right now I'm forced to use deprecated properties and functions to get the media out of those messages created with Twilio Chat, but I don't know if those will not work when the support for Chat ends.

What can I do?
Thanks!

Android and Web apparently does not have this issue.

This is the weird part, given that the format of the messages is the same.

Anyway, the legacy messages will not have the attachedMedia property (regardless of being on iOS, Android or Web) and you shall probably make your own wrapper for the legacy chat messages (i.e. check both media and attachedMedia).

Hello,

I believe this issue must be fixed in 2.2.0. Please update the dependency and report back.

Also TwilioAccessManager package is highly outdated and should be removed from podfile. All the token related notifications are included in the SDK.

Hi! Thanks for the response and for letting me know about TwilioAccessManager, I'll remove it and make adjustments later.

@Gray-Wind I updated to v2.2.0 and the issue is still there.
@berkus I can confirm that Android and Web don't have the same issue and that the API returns media even from old chat-created messages as part of the attachedMedia array while the iOS SDK shows that data on deprecated properties.

Screenshot with part of the payload with a media-typed message created with Twilio Chat
Request: https://conversations.twilio.com/v1/Services/{id}/Conversations/{id}/Messages
image
You can see the media as a unique element of the array.

Screenshot of the same message obtained with Twilio Conversations SDK for iOS
image
You can see the attachedMedia array empty and the data from the media on deprecated properties.

I am currently doing exactly what you recommend @berkus which is using the deprecated properties and functions for old chat-created messages with media and the new array for the conversations-created messages. The issue is that those properties and functions are marked as deprecated and I don't know if those will cease to function when Twilio ends support for Chat. Also, why is it an issue only for iOS?

What can I do?
Thanks

Thank you for the report! We got the reason behind the issue and will fix it in the near future. I will update this ticket once the fix will be available.

The issue is that those properties and functions are marked as deprecated and I don't know if those will cease to function when Twilio ends support for Chat. Also, why is it an issue only for iOS?

The deprecated methods will work after chat deprecation. They will be present until we release 3.0 version. But they will still work for older versions.

Also, why is it an issue only for iOS?

By the looks of it it cannot be the issue of iOS SDK only. Are you sure you are checking the same message in the other SDK?

Hello, the new version v2.2.3 has the fix for this issue. Feel free to create a new issue if something doesn't work.