kefu_flutter 1.0.1+4

  • Readme
  • Changelog
  • Example
  • Installing
  • 57

客服系统开发者QQ交流群: 623661658

欢迎使用本客服系统 - kefu_flutter #

本项目关联GIT项目资源连接 #

本系统 是基于小米消息云实现的一款简单实用的面向多终端的客服系统,本系统简单易用,易扩展,易整合现有的业务系统,无缝对接自有业务。

项目的依赖其他库 #

如果您也是用了以下库,存在版本冲突,可以尝试修改

    flutter_mimc: ^1.0.1
    dio: ^3.0.8
    image_picker: ^0.6.2+3
    shared_preferences: ^0.5.6
    provider: ^4.0.1
    flutter_advanced_networkimage: ^0.6.2
  

Android 你应该添加的权限 #

 <uses-permission android:name="android.permission.INTERNET"/>
 <uses-permission android:name="android.permission.CAMERA" />
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />​
    

IOS 你应该添加的权限 #

 <key>NSCameraUsageDescription</key>
 <key>NSPhotoLibraryUsageDescription</key>
    

EXAMPLE AND INSTALL #

dependencies: kefu_flutter: $lastVersion

import 'package:kefu_flutter/kefu_flutter.dart';


KeFuStore _keFu;

@override
void initState() {
    
    // 获得实例并监听数据动态 (1)
    // 单列 获取对象
    /// 配置信息
    /// mImcTokenData 不为空,即优先使用 mImcTokenData
    /// [apiHost] 客服后台API地址
    /// [mImcAppID]     mimc AppID
    /// [mImcAppKey]    mimc AppKey
    /// [mImcAppSecret] mimc AppSecret
    /// [mImcTokenData] mimc TokenData 服务端生成
    /// [userId]        业务平台ID(扩展使用)
    /// [autoLogin]     是否自动登录
    /// [delayTime]     延迟登录,默认1500毫秒,以免未实例化完成就调用登录
    _keFu = KeFuStore.getInstance(
        debug: true,
        autoLogin: true,
        host: "http://kf.aissz.com:666/v1",
        appID: "",
        appKey: "",
        appSecret: ""
    );

    /// 获得实例并监听数据动态 (2)
    _keFu.addListener(() async{
        await Future.delayed(Duration(milliseconds: 200));
        debugPrint("_keFu对象变动");
        _keFu = KeFuStore.instance;
        if(mounted) setState(() {});
    });

    /// 或者设置不自动登录,自己手动登录
    /// _keFu.loginIm()

    super.initState();

}

/// 获得客服页面视图
_keFu.view();

/// 然后记得销毁
@override
void dispose() {
    _keFu?.dispose();
    super.dispose();
}


  

[1.0.1+4] - TODO: Add release date. #

  • TODO: Fix upload image no avatar

[1.0.1+3] - TODO: Add release date. #

  • TODO: Fix upload image problem

[1.0.1+2] - TODO: Add release date. #

  • TODO: change instance function
  • TODO: add example Adroid permission

[1.0.1+1] - TODO: Add release date. #

  • TODO: format all file
  • TODO: Update README.md

[1.0.1] - TODO: Add release date. #

  • TODO: update varsion code
  • TODO: update init is not complete and show tips

[0.0.2] - TODO: Add release date. #

  • TODO: format all file
  • TODO: Support 1.12.13 + hotfix.5

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kefu_flutter/kefu_flutter.dart';

void main(){
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle(statusBarColor: Color.fromRGBO(0, 0, 0, 0.0)));
  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
  return runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: '在线客服',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        brightness: Brightness.light,
        primaryColor: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter 在线客服 DEMO'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  KeFuStore _keFu;

  void _action() {
    Navigator.push(context, CupertinoPageRoute(builder: (ctx){
      return _keFu.view();
    }));
  }

  @override
  void initState() {

      // 获得实例并监听数据动态 (1)
      // 单列 获取对象
      /// 配置信息
      /// mImcTokenData 不为空,即优先使用 mImcTokenData
      /// [apiHost] 客服后台API地址
      /// [mImcAppID]     mimc AppID
      /// [mImcAppKey]    mimc AppKey
      /// [mImcAppSecret] mimc AppSecret
      /// [mImcTokenData] mimc TokenData 服务端生成
      /// [userId]        业务平台ID(扩展使用)
      /// [autoLogin]     是否自动登录
      /// [delayTime]     延迟登录,默认1500毫秒,以免未实例化完成就调用登录
      _keFu = KeFuStore.getInstance(
          debug: true,
          autoLogin: true,
          host: "http://kf.aissz.com:666/v1",
          appID: "2882303761518282099",
          appKey: "5521828290099",
          appSecret: "516JCA60FdP9bHQUdpXK+Q=="
      );

      // 获得实例并监听数据动态 (2)
      _keFu.addListener(() async{
          await Future.delayed(Duration(milliseconds: 200));
          debugPrint("_keFu对象变动");
          _keFu = KeFuStore.instance;
          if(mounted) setState(() {});
      });


    super.initState();

  }


  @override
  void dispose() {
    _keFu?.dispose();
    super.dispose();
  }


  @override
  Widget build(BuildContext context) {
    ThemeData themeData = Theme.of(context);
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            RichText(
              text: TextSpan(
                style: TextStyle(
                  color: Colors.black
                ),
                children: [
                  TextSpan(text: "用户id: ${_keFu.imUser?.id ?? 0}   "),
                  TextSpan(text: "${_keFu.messageReadCount}", style: TextStyle(
                    color: Colors.deepOrange,
                    fontSize: 30.0,
                    fontWeight: FontWeight.w600
                  )),
                  TextSpan(text: "条未读消息"),
                ]
              ),
            ),
            Text(
              '欢迎使用在线客服',
            ),
            RaisedButton(
                color: themeData.primaryColor,
                child: Text("联系客服", style: TextStyle(color: Colors.white),), onPressed: () => _action()
            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  kefu_flutter: ^1.0.1+4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:kefu_flutter/kefu_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
18
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
57
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (flutter_advanced_networkimage).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cupertino_icons ^0.1.3 0.1.3
dio ^3.0.8 3.0.9
flutter 0.0.0
flutter_advanced_networkimage ^0.6.2 0.6.4 0.7.0
flutter_mimc ^1.0.1 1.0.1
image_picker ^0.6.2+3 0.6.4
provider ^4.0.1 4.0.4 4.1.0-dev+2
shared_preferences ^0.5.6 0.5.6+3
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.11 1.14.12
convert 2.1.1
flutter_plugin_android_lifecycle 1.0.6
flutter_svg 0.17.3+1
flutter_web_plugins 0.0.0
http 0.12.0+4
http_parser 3.1.4
meta 1.1.8
nested 0.0.4
path 1.6.4
path_drawing 0.4.1
path_parsing 0.1.4
path_provider 1.6.5
path_provider_macos 0.0.4
path_provider_platform_interface 1.0.1
pedantic 1.9.0
petitparser 3.0.1
platform 2.2.1
plugin_platform_interface 1.0.2
shared_preferences_macos 0.0.1+6
shared_preferences_platform_interface 1.0.3
shared_preferences_web 0.1.2+4
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
xml 3.7.0
Dev dependencies
flutter_test