diff --git a/android/app/src/play/java/chat/rocket/reactnative/Ejson.java b/android/app/src/play/java/chat/rocket/reactnative/Ejson.java index fb083df13..c5ee7595c 100644 --- a/android/app/src/play/java/chat/rocket/reactnative/Ejson.java +++ b/android/app/src/play/java/chat/rocket/reactnative/Ejson.java @@ -34,6 +34,8 @@ public class Ejson { String senderName; String msg; + String tmid; + private MMKV mmkv; private String TOKEN_KEY = "reactnativemeteor_usertoken-"; diff --git a/android/app/src/play/java/chat/rocket/reactnative/ReplyBroadcast.java b/android/app/src/play/java/chat/rocket/reactnative/ReplyBroadcast.java index ef1579b51..10e48e32f 100644 --- a/android/app/src/play/java/chat/rocket/reactnative/ReplyBroadcast.java +++ b/android/app/src/play/java/chat/rocket/reactnative/ReplyBroadcast.java @@ -123,7 +123,9 @@ public class ReplyBroadcast extends BroadcastReceiver { if (msg != message) { msgMap.put("t", "e2e"); } - msgMap.put("tmid", null); + if(ejson.tmid != null) { + msgMap.put("tmid", ejson.tmid); + } Map m = new HashMap(); m.put("message", msgMap); diff --git a/ios/ReplyNotification.swift b/ios/ReplyNotification.swift index 771a1056d..5d0840632 100644 --- a/ios/ReplyNotification.swift +++ b/ios/ReplyNotification.swift @@ -34,7 +34,7 @@ class ReplyNotification: RNNotificationEventHandler { if let msg = (response as? UNTextInputNotificationResponse)?.userText { let rocketchat = RocketChat.instanceForServer(server: payload.host.removeTrailingSlash()) let backgroundTask = UIApplication.shared.beginBackgroundTask(expirationHandler: nil) - rocketchat.sendMessage(rid: rid, message: msg) { response in + rocketchat.sendMessage(rid: rid, message: msg, threadIdentifier: payload.tmid) { response in guard let response = response, response.success else { let content = UNMutableNotificationContent() content.body = "Failed to reply message." diff --git a/ios/Shared/Models/Payload.swift b/ios/Shared/Models/Payload.swift index 9e5f52675..a7db8fdbc 100644 --- a/ios/Shared/Models/Payload.swift +++ b/ios/Shared/Models/Payload.swift @@ -19,4 +19,5 @@ struct Payload: Codable { let messageType: MessageType? let msg: String? let senderName: String? + let tmid: String? } diff --git a/ios/Shared/RocketChat/RocketChat.swift b/ios/Shared/RocketChat/RocketChat.swift index 766f5fc63..294bfebce 100644 --- a/ios/Shared/RocketChat/RocketChat.swift +++ b/ios/Shared/RocketChat/RocketChat.swift @@ -52,7 +52,7 @@ final class RocketChat { } } - func sendMessage(rid: String, message: String, completion: @escaping((MessageResponse?) -> Void)) { + func sendMessage(rid: String, message: String, threadIdentifier: String?, completion: @escaping((MessageResponse?) -> Void)) { let id = String.random(length: 17) var msg = message @@ -61,7 +61,7 @@ final class RocketChat { msg = encryptMessage(rid: rid, id: id, message: message) } - api?.fetch(request: SendMessageRequest(id: id, roomId: rid, text: msg, messageType: encrypted ? .e2e : nil )) { response in + api?.fetch(request: SendMessageRequest(id: id, roomId: rid, text: msg, threadIdentifier: threadIdentifier, messageType: encrypted ? .e2e : nil )) { response in switch response { case .resource(let response): completion(response)