Giter Site home page Giter Site logo

flutter_qiyu's Introduction

flutter_qiyu

适用于 Flutter 的七鱼客服插件

快速开始

安装

将此添加到包的 pubspec.yaml 文件中:

dependencies:
  flutter_qiyu: ^0.0.1

您可以从命令行安装软件包:

$ flutter packages get

用法

初始化 SDK

QiYu.registerApp(
  appKey: '<appKey>',
  appName: 'qiyu example',
);

由于七鱼版本升级,Android 平台需要在 Application#onCreate 中调用初始化 SDK 方法,请修改以下文件(完整示例参见 example 目录)。

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.blankapp.flutterplugins.flutter_qiyu_example">

    ...

    <application
-        android:name="io.flutter.app.FlutterApplication"
+        android:name=".MainApplication"
        android:icon="@mipmap/ic_launcher"
        android:label="flutter_qiyu_example"
+        android:networkSecurityConfig="@xml/network_security_config">

        ...

    </application>
</manifest>

MainApplication.java

package org.blankapp.flutterplugins.flutter_qiyu_example;

import org.blankapp.flutterplugins.flutter_qiyu.FlutterQiyuPlugin;

import io.flutter.app.FlutterApplication;

public class MainApplication extends FlutterApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        FlutterQiyuPlugin.initSDK(this, "<appKey>");
    }
}

上报用户信息

QYUserInfoParams userInfoParams = QYUserInfoParams.fromJson({
  'userId': 'uid10101010',
  'data':
      '[{\"key\":\"real_name\", \"value\":\"土豪\"},{\"key\":\"mobile_phone\", \"hidden\":true},{\"key\":\"email\", \"value\":\"[email protected]\"},{\"index\":0, \"key\":\"account\", \"label\":\"账号\", \"value\":\"zhangsan\", \"href\":\"http://example.domain/user/zhangsan\"},{\"index\":1, \"key\":\"sex\", \"label\":\"性别\", \"value\":\"先生\"},{\"index\":5, \"key\":\"reg_date\", \"label\":\"注册日期\", \"value\":\"2015-11-16\"},{\"index\":6, \"key\":\"last_login\", \"label\":\"上次登录时间\", \"value\":\"2015-12-22 15:38:54\"}]'
});
QiYu.setUserInfo(userInfoParams);

打开服务窗口

QYServiceWindowParams serviceWindowParams =
    QYServiceWindowParams.fromJson({
  'source': {
    'sourceTitle': '网易七鱼Flutter',
    'sourceUrl': 'http://www.qiyukf.com',
    'sourceCustomInfo': '我是来自自定义的信息'
  },
  'commodityInfo': {
    'commodityInfoTitle': 'Flutter商品',
    'commodityInfoDesc': '这是来自网易七鱼Flutter的商品描述',
    'pictureUrl':
        'http://qiyukf.com/res/img/companyLogo/blmn.png',
    'commodityInfoUrl': 'http://www.qiyukf.com',
    'note': '¥1000',
    'show': true
  },
  'sessionTitle': '网易七鱼123',
  'groupId': 0,
  'staffId': 0,
  'robotId': 0,
  'robotFirst': false,
  'faqTemplateId': 0,
  'vipLevel': 0,
  'showQuitQueue': true,
  'showCloseSessionEntry': true
});
QiYu.openServiceWindow(serviceWindowParams);

获取未读消息数

// 直接获取未读消息数
QiYu.getUnreadCount().then((unreadCount) {
  setState(() {
    _unreadCount = unreadCount;
  });
});
// 监听未读消息数变化
QiYu.onUnreadCountChange((unreadCount) {
  setState(() {
    _qiyuUnreadCount = unreadCount;
  });
});

自定义客服聊天窗口 UI

var params = {
  //
};
QiYu.setCustomUIConfig(params)

详情参数说明同官方 react-native-qiyu 插件: https://github.com/qiyukf/react-native-qiyu#-setcustomuiconfig

相关链接

许可证

MIT License

Copyright (c) 2020 LiJianying <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

flutter_qiyu's People

Contributors

lijy91 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.