From 9cc56d659d128495974155b512a43dbfa1ce05a0 Mon Sep 17 00:00:00 2001 From: jackning <270580156@qq.com> Date: Tue, 6 Oct 2020 11:09:20 +0800 Subject: [PATCH] update to 0.0.8 --- README.md | 2 +- bytedesk_demo/README.md | 2 +- bytedesk_demo/lib/main.dart | 23 ++++++++++++----------- bytedesk_demo/pubspec.yaml | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d9c5fd4..e19a298 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ### 第二步:匿名登录 -- BytedeskKefu.anonymousLogin(appKey, subDomain); +- BytedeskKefu.anonymousLogin(_androidKey, _iOSKey, _subDomain); ### 第三步:联系客服 diff --git a/bytedesk_demo/README.md b/bytedesk_demo/README.md index d9c5fd4..e19a298 100644 --- a/bytedesk_demo/README.md +++ b/bytedesk_demo/README.md @@ -13,7 +13,7 @@ ### 第二步:匿名登录 -- BytedeskKefu.anonymousLogin(appKey, subDomain); +- BytedeskKefu.anonymousLogin(_androidKey, _iOSKey, _subDomain); ### 第三步:联系客服 diff --git a/bytedesk_demo/lib/main.dart b/bytedesk_demo/lib/main.dart index ec30f03..4e12019 100644 --- a/bytedesk_demo/lib/main.dart +++ b/bytedesk_demo/lib/main.dart @@ -1,6 +1,6 @@ import 'package:bytedesk_kefu/bytedesk_kefu.dart'; -import 'package:bytedesk_kefu/util/constants.dart'; -import 'package:bytedesk_kefu/util/events.dart'; +import 'package:bytedesk_kefu/util/bytedesk_constants.dart'; +import 'package:bytedesk_kefu/util/bytedesk_events.dart'; import 'package:flutter/material.dart'; void main() { @@ -14,11 +14,12 @@ void main() { // 参考文档:https://github.com/pengjinning/bytedesk-android // appkey和subDomain请替换为真实值 // 获取appkey,登录后台->客服管理->渠道管理->添加应用->appkey - String _appKey = "201809171553112"; + String _androidKey = "66390193-b2c1-4edb-aa5f-50b1541059e8"; + String _iOSKey = "201809171553112"; // 获取subDomain,也即企业号:登录后台->客服管理->客服账号->企业号 String _subDomain = "vip"; // 第一步:匿名登录 - BytedeskKefu.anonymousLogin(_appKey, _subDomain); + BytedeskKefu.anonymousLogin(_androidKey, _iOSKey, _subDomain); } class MyApp extends StatefulWidget { @@ -64,28 +65,28 @@ class _MyAppState extends State { // 监听状态 _listener() { // 监听连接状态 - eventBus.on().listen((event) { + bytedeskEventBus.on().listen((event) { print('长连接状态:' + event.content); - if (event.content == BDConstants.USER_STATUS_CONNECTING) { + if (event.content == BytedeskConstants.USER_STATUS_CONNECTING) { setState(() { _title = "萝卜丝客服Demo(连接中...)"; }); - } else if (event.content == BDConstants.USER_STATUS_CONNECTED) { + } else if (event.content == BytedeskConstants.USER_STATUS_CONNECTED) { setState(() { _title = "萝卜丝客服Demo(连接成功)"; }); - } else if (event.content == BDConstants.USER_STATUS_DISCONNECTED) { + } else if (event.content == BytedeskConstants.USER_STATUS_DISCONNECTED) { setState(() { _title = "萝卜丝客服Demo(连接断开)"; }); } }); // 监听消息 - eventBus.on().listen((event) { + bytedeskEventBus.on().listen((event) { // print('receive message:' + event.message.content); - if (event.message.type == BDConstants.MESSAGE_TYPE_TEXT) { + if (event.message.type == BytedeskConstants.MESSAGE_TYPE_TEXT) { print('文字消息: ' + event.message.content); - } else if (event.message.type == BDConstants.MESSAGE_TYPE_IMAGE) { + } else if (event.message.type == BytedeskConstants.MESSAGE_TYPE_IMAGE) { print('图片消息:' + event.message.imageUrl); } else { print('其他类型消息'); diff --git a/bytedesk_demo/pubspec.yaml b/bytedesk_demo/pubspec.yaml index 1e91092..7e95063 100644 --- a/bytedesk_demo/pubspec.yaml +++ b/bytedesk_demo/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: sdk: flutter # https://pub.dev/packages/bytedesk_kefu - bytedesk_kefu: ^0.0.2 + bytedesk_kefu: ^0.0.8 # The following adds the Cupertino Icons font to your application.