markUnread method
Implementation
Future<MarkThreadResult> markUnread(String? tid) async {
//
String? uid = SpUtil.getString(BytedeskConstants.uid);
//
var body = json.encode({'tid': tid, 'uid': uid, 'client': client});
final threadUrl = BytedeskUtils.getHostUri(
'/api/v2/thread/mark/unread',
);
final initResponse =
await httpClient.post(threadUrl, headers: getHeaders(), body: body);
//解决json解析中的乱码问题
Utf8Decoder utf8decoder = const Utf8Decoder(); // fix 中文乱码
//将string类型数据 转换为json类型的数据
final responseJson =
json.decode(utf8decoder.convert(initResponse.bodyBytes));
// debugPrint("responseJson $responseJson");
// 判断token是否过期
if (responseJson.toString().contains('invalid_token')) {
bytedeskEventBus.fire(InvalidTokenEventBus());
}
return MarkThreadResult.fromJson(responseJson);
}