twilio / conversations-ios

SPM releases
https://www.twilio.com/docs/conversations/ios/changelog
10 stars 5 forks source link

TCHMessageOptions - completion never called when setting attributes #8

Closed tomhut closed 3 years ago

tomhut commented 3 years ago

Hi,

Since updating to the latest version of the framework it seems the callback closure is never called when adding attributes to TCHMessageOptions. Although this is not critical to our app, we do use these to attach the aspect ratio of an image so a correct sized placeholder can be shown in the message list whilst the image is downloaded.

Any help would be greatly appreciated, in version 1.2.0 the callback is fired successfully.

let messageOptions = TCHMessageOptions()
//messageOptions.withMediaStream... omitted for brevity
let optionAttributes = TCHJsonAttributes(dictionary: [
    "exampleKey": "exampleValue"
])

guard let optionAttributes = optionAttributes else {
    throw MessageSendError.invalidAttributes
}

messageOptions.withAttributes(optionAttributes) { result in
    debugPrint(result) //Never called
}
Pavel-Cherentsov commented 3 years ago

Hi! withAttributes is synchronous, it just remembers completion callback in TCHMessageOptions object and returns immediately.

This completion callback would be called later, on message sending, when this TCHMessageOptions object is passed to [TCHMessages sendMessageWithOptions]. By the way, sendMessageWithOptions method also has its own completion callback, it will be called on send completion.

So TCHMessageOptions completion callback would be called right before actual sending started, and sendMessageWithOptions completion callback is called after message is sent.

Sorry that documentation is not clear.

Gray-Wind commented 3 years ago

We have plans to fix this behaviour, but this time we decided not to make breaking release to make it work more logical. For now we are closing this issue, but keep an eye on updates.

tomhut commented 3 years ago

@Pavel-Cherentsov @Gray-Wind Thank you both!