urva_connect_sdk_main 0.0.4 copy "urva_connect_sdk_main: ^0.0.4" to clipboard
urva_connect_sdk_main: ^0.0.4 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.4

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 {
      isLoading.value = true;

      await UrvaConnectSdk.fetchConnectData();
      isLoading.value = false;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text(widget.title)),
        body: 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);
                            UrvaConnectSdk.openScreen(
                              context,
                              isSystemBack: true,
                              onClickCustomModule: (context, shortcut) {
                                log("shortcut data => ${shortcut.toJson()}");
                                Navigator.of(context).push(
                                    MaterialPageRoute<dynamic>(
                                        builder: (context) => CustomModule(shortCut: shortcut)));
                              },
                            );
                          },
                          child: Text("Open Urva Connect"),
                        ),

                        ElevatedButton(
                          onPressed: () {
                            UrvaConnectSdk.logoutUrvaConnect();
                          },
                          child: Text("Logout"),
                        ),
                      ],
                    );
                  }
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Custom theme color pass

await UrvaConnectSdk.initializeSdk(
    baseUrl: "BASE_URL",
    userToken: "USER_AUTH_TOKEN",
    companyToken: "COMAPANY_TOKEN",
    themeColor: ThemeColor(
      themeColor1dark: "#CCD2EC",
      themeColor1Light: "#182144",
      themeColor2dark: "#182144",
      themeColor2Light: "#CCD2EC",
    ),
  );
  

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,);

Clear connect data and logout user

 UrvaConnectSdk.logoutUrvaConnect();

for full example, please see this Demo.