engage_plugin 1.2.18 copy "engage_plugin: ^1.2.18" to clipboard
engage_plugin: ^1.2.18 copied to clipboard

This plugin allows you to use the TeamViewer Engage co-broswing and live-chat SDK for both Android and iOS platforms.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:engage_plugin/engage_plugin.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

Future main() async {
  await dotenv.load(fileName: ".env");
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  static var chatOverlayEnabled = false;
  final _engagePlugin = EngagePlugin();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  var initConfig = InitConfig(
      dotenv.env['TENANT']!,
      dotenv.env['TOKEN']!,
      dotenv.env['SERVERURL']!,
      dotenv.env['CDNSERVERURL']!,
      chatOverlayEnabled,
      ["deeplinkurl(optional"],
      dotenv.env['OVERLAYBACKGROUNDCOLOR']!,
      dotenv.env['CONTROLCOLORS']!);

  var tagUserInfo =
      TagUserInfo(
          ["Labels", "list"],
          "Email",
          "FirstName",
          "LastName",
          "ID",
          "AssignedUser",
          "ExternalToken",
          {"Key":"Data"});

  Future<void> initPlatformState() async {
    try {
      await _engagePlugin.init(initConfig);
    } on PlatformException {
      'failed to init engage';
    }

    if (!mounted) {
      return;
    }

    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Engage plugin example'),
        ),
        body: Center(
            child: Column(
          children: [
            ElevatedButton(
                onPressed: (() => _engagePlugin.init(initConfig)),
                child: const Text('Init Plugin')),
            ElevatedButton(
                onPressed: () => _engagePlugin.openChat(),
                child: const Text('Open Chat')),
            ElevatedButton(
                onPressed: () => _engagePlugin.startCoBrowsing(),
                child: const Text('Open coBrowser')),
            ElevatedButton(
                onPressed: () => _engagePlugin.stopCoBrowsing(),
                child: const Text('Stop coBrowser')),
            ElevatedButton(
                onPressed: () => _engagePlugin.tagUser(tagUserInfo),
                child: const Text('Tag user')),
            ElevatedButton(
                onPressed: () => _engagePlugin.clear(),
                child: const Text('Clear')),
          ],
        )),
      ),
    );
  }
}
1
likes
130
pub points
7%
popularity

Publisher

unverified uploader

This plugin allows you to use the TeamViewer Engage co-broswing and live-chat SDK for both Android and iOS platforms.

Homepage

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on engage_plugin