urva_connect_sdk_main 0.0.6 copy "urva_connect_sdk_main: ^0.0.6" to clipboard
urva_connect_sdk_main: ^0.0.6 copied to clipboard

Urva connect sdk used for urva support chat

urva-connect-sdk-flutter #

A comprehensive Flutter SDK for integrating Urva's support chat functionality into your mobile applications. This SDK provides a complete solution for building feature-rich chat applications with support for text messaging, media sharing, notifications, and more.

Features #

  • Real-time Chat: Socket.io-based real-time messaging
  • Media Support: Image, video, audio, and document sharing
  • Rich UI Components: Reactions, mentions, link previews, and markdown support
  • Notifications: Local and push notifications with customizable sounds
  • Security: End-to-end encryption, certificate pinning, and secure storage
  • Offline Support: Cached messages and offline file handling
  • Multi-platform: iOS and Android support with platform-specific optimizations
  • Theming: Dark/light theme support with customizable colors
  • File Management: PDF viewer, image picker, and file compression
  • Audio/Video: Voice messages, TTS, and video playback
  • Connectivity: Network state monitoring and automatic reconnection

Getting Started #

Prerequisites #

  • Flutter SDK ^3.9.2
  • Dart SDK ^3.9.2
  • iOS 11.0+ or Android API 21+

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  ...
  urva_connect_sdk_main: ^0.0.6

In your library add the following import:

import 'package:urva_connect_sdk_main/urva_connect_sdk_main.dart';

For help getting started with Flutter, view the online documentation.

Usage #

First initialize the sdk

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await UrvaConnectSdk.initializeSdk(
    baseUrl: "BASE_URL",
    userToken: "USER_AUTH_TOKEN",
    companyToken: "COMAPANY_TOKEN",
  );
  runApp(MultiProvider(providers: [
    ...UrvaConnectProvider.allProvider
  ], child: MyApp(),));
}

Example for Urva connect sdk

class _MyHomePageState extends State<MyHomePage> {
  ValueNotifier<bool> isLoading = ValueNotifier(false);

  @override
  void initState() {
    ///unique id is unique phone number, email id, or userId
    ///token is your api key generated from urva connect dashboard
    super.initState();

    WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
      await loadData();
    });

    UrvaConnectSdk.connectActionCallbacks(context, (context, shortcut) {
      log("shortcut data => ${shortcut.toJson()}");
      Navigator.of(context).push(
        MaterialPageRoute<dynamic>(
          builder: (context) => CustomModule(shortCut: shortcut),
        ),
      );
    });
  }

  Future<void> loadData({bool hardRefresh = false}) async {
    isLoading.value = true;
    await UrvaConnectSdk.fetchConnectData(hardRefresh: hardRefresh);
    if (mounted) {
      UrvaConnectSdk.setThemeColor(context, ThemeColor(
        tmColor1: OrgColor(lightColor: "#ab292e", darkColor: "#ee7e1e"),
        tmColor2: OrgColor(lightColor: "#ee7e1e", darkColor: "#ab292e"),
      ));
    }
    isLoading.value = false;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text(widget.title)),
        body: home,

      ),
    );
  }



  Widget get home {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [ValueListenableBuilder(
          valueListenable: isLoading,
          builder: (context, value, child) {
            if (value) {
              return CircularProgressIndicator();
            } else {
              return Column(
                spacing: 15,
                children: [
                  ElevatedButton(
                    onPressed: () {
                      UrvaConnectSdk.setThemeMode(Brightness.light);
                      Navigator.of(context).push(
                        MaterialPageRoute<dynamic>(
                          builder: (context) =>
                          Home(),
                        ),
                      );
                    },
                    child: Text("Open Urva Connect"),
                  ),
                  ElevatedButton(
                    onPressed: () async {
                      loadData(hardRefresh: true);
                    },
                    child: Text("Refresh"),
                  ),
                  ElevatedButton(
                    onPressed: () {
                      UrvaConnectSdk.logoutUrvaConnect();
                    },
                    child: Text("Logout"),
                  ),
                ],
              );
            }
          },
        )],
      ),
    );
  }


}

Custom theme color pass

UrvaConnectSdk.setThemeColor(context, ThemeColor(
        tmColor1: OrgColor(lightColor: "#ab292e", darkColor: "#ee7e1e"),
        tmColor2: OrgColor(lightColor: "#ee7e1e", darkColor: "#ab292e"),
        ...
      ));
  

If show custom button show in thread profile screen and revert callback

await UrvaConnectSdk.initializeSdk(
    customActionButtons: [
      CustomActionButton(
        header: "Custom Button 1",
        shortCut: ShortCut(module: "custom_module", screen: "1"),
      ),
      CustomActionButton(
        header: "Custom Button 2",
        subline1: "sub line 2",
        shortCut: ShortCut(module: "custom_module", screen: "2"),
      ),
      CustomActionButton(
        header: "Custom Button 3",
        subline1: "sub line 3",
        icon: "home",
        shortCut: ShortCut(module: "custom_module", screen: "3"),
      ),
      CustomActionButton(
        header: "Custom Button 4",
        subline1: "sub line 4",
        icon: "check_circle",
      ),
    ],
  );

Change connect theme light/dark mode , please follow the code firstly set theme then open screen

 UrvaConnectSdk.setThemeMode(Brightness.dark);
 UrvaConnectSdk.openScreen(context,isSystemBack: true,);

All connect click callback and also custom action button callback use fo this

UrvaConnectSdk.connectActionCallbacks(context, (context, shortcut) {
      log("shortcut data => ${shortcut.toJson()}");
      Navigator.of(context).push(
        MaterialPageRoute<dynamic>(
          builder: (context) => CustomModule(shortCut: shortcut),
        ),
      );
    });

Clear connect data and logout user

 UrvaConnectSdk.logoutUrvaConnect();

for full example, please see this Demo.