subscribeToThread static method
Future<String?>
subscribeToThread(
- int parentMessageId, {
- dynamic onSuccess(
- String result
- dynamic onError(
- CometChatException excep
Subscribes the logged-in user to the thread rooted at
parentMessageId, so they are notified about replies that arrive in
future — allowed even on a message with zero replies.
The call is idempotent: subscribing to an already-followed thread succeeds (200) and is not an error. The resolved call is the acknowledgement — there is no follow-up event. Subscription state is read off fetched messages via BaseMessage.threadSubscribed.
Implementation
static Future<String?> subscribeToThread(int parentMessageId,
{Function(String response)? onSuccess,
Function(CometChatException e)? onError}) async {
try {
final sdk = SdkRegistry.getInstance();
final result = await sdk.threads.subscribeToThread(parentMessageId);
if (onSuccess != null) onSuccess(result);
return result;
} on SdkException catch (sdkEx) {
final cometChatEx = CometChatException(
sdkEx.code,
sdkEx.details ?? sdkEx.message,
sdkEx.message,
);
_errorCallbackHandler(cometChatEx, null, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
return null;
}