diff --git a/ios/Wrappers/DecodedMessageWrapper.swift b/ios/Wrappers/DecodedMessageWrapper.swift index 72d6c2368..5820d5334 100644 --- a/ios/Wrappers/DecodedMessageWrapper.swift +++ b/ios/Wrappers/DecodedMessageWrapper.swift @@ -13,6 +13,7 @@ struct DecodedMessageWrapper { "senderAddress": model.senderAddress, "sent": UInt64(model.sentAt.timeIntervalSince1970 * 1000), "fallback": model.encodedContent.fallback, + "shouldPush": model.shouldPush ] } diff --git a/ios/XMTPModule.swift b/ios/XMTPModule.swift index 5ab661e2d..22aae0f65 100644 --- a/ios/XMTPModule.swift +++ b/ios/XMTPModule.swift @@ -226,14 +226,16 @@ public class XMTPModule: Module { ).toJson() } - AsyncFunction("sendEncodedContent") { (clientAddress: String, topic: String, encodedContentData: [UInt8]) -> String in + AsyncFunction("sendEncodedContent") { (clientAddress: String, topic: String, encodedContentData: [UInt8], shouldPush: Bool) -> String in guard let conversation = try await findConversation(clientAddress: clientAddress, topic: topic) else { throw Error.conversationNotFound("no conversation found for \(topic)") } let encodedContent = try EncodedContent(serializedData: Data(encodedContentData)) + + let options = SendOptions(contentType: encodedContent.type, shouldPush: shouldPush) - return try await conversation.send(encodedContent: encodedContent) + return try await conversation.send(encodedContent: encodedContent, options: options) } AsyncFunction("listConversations") { (clientAddress: String) -> [String] in @@ -390,15 +392,19 @@ public class XMTPModule: Module { AsyncFunction("prepareEncodedMessage") { ( clientAddress: String, conversationTopic: String, - encodedContentData: [UInt8] + encodedContentData: [UInt8], + shouldPush: Bool ) -> String in guard let conversation = try await findConversation(clientAddress: clientAddress, topic: conversationTopic) else { throw Error.conversationNotFound("no conversation found for \(conversationTopic)") } let encodedContent = try EncodedContent(serializedData: Data(encodedContentData)) + + let contentType = encodedContent.type let prepared = try await conversation.prepareMessage( - encodedContent: encodedContent + encodedContent: encodedContent, + options: SendOptions(contentType: contentType, shouldPush: shouldPush) ) let preparedAtMillis = prepared.envelopes[0].timestampNs / 1_000_000 let preparedData = try prepared.serializedData()