bindChatControllers method
make sure you init v chat in the Home page of you app to start receive notifications when you call this function the user will be online and can receive notification first you have to login or register in v chat other wise will throw Exception
Implementation
Future<void> bindChatControllers({
required BuildContext context,
String? email,
}) async {
if (VChatAppService.instance.vChatUser == null && email == null) {
return;
// throw VChatSdkException(
// "You must login or register to v chat first if you migrate old users then send email parameter is required",
// );
}
if (VChatAppService.instance.vChatUser == null && email != null) {
try {
await login(context: context, email: email);
} catch (err) {
throw "Your Not found in vchat database please make sure you mirage the old users passwordHash Key must be the same on flutter and backend .env $err";
}
return;
}
if (!_getIt.isRegistered<SocketService>()) {
_getIt.registerSingleton(SocketService());
}
final preferences = SharedPrefsInstance.instance;
final appLang = preferences.getString(StorageKeys.kvChatAppLanguage);
if (appLang != null) {
VChatAppService.instance.currentLocal = appLang;
unawaited(_vChatUsersApi.updateUserLanguage(appLang));
}
unawaited(NotificationService.instance.init(context));
RoomCubit.instance.getInstance();
}