handleMethod method
Implementation
Future<dynamic> handleMethod(MethodCall call) async {
switch (call.method) {
case "on_notification_clicked":
debugPrint("TencentCloudChatPush: ${call.arguments}");
final ext = call.arguments.toString();
if (_onNotificationClicked == null) {
// 回调尚未注册(registerPush 还未 await 到 registerOnNotificationClickedEvent),
// 先缓存 ext,待 [onNotificationClicked] setter 赋值时立即回放。
_pendingOnClickExt = ext;
break;
}
final ParseExtInfoResult conversationInfo = TencentCloudChatPushUtils.parseExtInfo(ext);
_onNotificationClicked!.call(
ext: ext,
userID: conversationInfo.userID,
groupID: conversationInfo.groupID,
);
break;
case "on_app_wake_up":
onAppWakeUp?.call();
break;
case "onRecvPushMessage":
debugPrint("onRecvPushMessage: ${TimPushMessage.fromJson(call.arguments).toLogString()}");
timPushListenerList.forEach((listener) {
try {
listener.onRecvPushMessage(TimPushMessage.fromJson(call.arguments));
} catch (err, errorStack) {
debugPrint("$err $errorStack");
}
});
break;
case "onRevokePushMessage":
debugPrint("onRevokePushMessage: ${call.arguments.toString()}");
timPushListenerList.forEach((listener) {
try {
listener.onRevokePushMessage(call.arguments.toString());
} catch (err, errorStack) {
debugPrint("$err $errorStack");
}
});
break;
case "onNotificationClicked":
debugPrint("onNotificationClicked: ${call.arguments.toString()}");
mNotificationExtInfo = call.arguments.toString();
notificationClicked();
break;
default:
throw UnsupportedError("Unrecognized Event");
}
}