flutter_wx_message 0.0.13
flutter_wx_message: ^0.0.13 copied to clipboard
Flutter plugin for wechat,get contacts,get chat message.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_wx_message/flutter_wx_message.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _wx = FlutterWxMessage();
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion = await _wx.getPlatformVersion() ?? 'Unknown platform version';
// await _wx.permission();
// var res = await _phone.getSim();
// print("res:fluter:sim:");
// print(res);
// _wx.toCall({"phone":"13578021300","id":0});
//获取通话记录和录音&&上传
String _t = "bf74beb91016ba75d6996e74554e5ed2"; //此处自行替换
String env = "dev"; //此处自行替换(录音文件存储目录:prod:正式 test:测试 dev:开发)
String identification = "4444.4d507500cc7a53983332"; //此处自行替换
Map map = {
"_t": _t,
"domain": "http://192.168.110.14:9514", //此处自行替换 https://dtms-h5.kyhgw.cn
"endpoint": "https://oss-cn-beijing.aliyuncs.com", //oss区域对应域名(固定)
"bucketName": "kingchem", //bucketName(固定)
"identification": identification, //此处替换
"stsServer": "/api/audio/securityToken", //获取oss鉴权信息(域名+接口地址+当前登录token)
"time": 86400 * 4 * 1000, //通话录音-时间范围
"dir": "dtms/"+env+"/audio/" + identification + "/", //通话录音-录音文件上传目录
"uploadAlways": 0, //通话录音-(未实现)缓存是否已上传录音文件:0是,1不
"logsPush": "/api/audio/logsPush", //通话录音-运行时日志推送
"callSaveServer": "/mobile/call/saveLog", //通话录音-通话记录上传
"audioStatusServer": "/mobile/call/noticeUpload", //通话录音-更新录音状态接口
"wxContactsSave": "/api/wechat/wxContactsSave", //微信信息-好友同步接口
"wxMessagesSave": "/api/wechat/wxMessagesSave", //微信信息-消息同步接口
"wxDir": 'dtms/$env/wx/', //微信信息-文件上传目录
"wxWaitTime": 15, //微信信息-同步间隔(防止重复运行、每次循环休眠)
"wxTimeout": 30, //微信信息-重试间隔(异常崩溃、无响应)
"wxMsgChatroom": false, //微信信息-消息是否读取群消息
"wxMsgSize": 666, //微信信息-消息分页数
"wxLoop": 500, //微信信息-循环同步次数
};
_wx.appTask(map);
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
),
),
);
}
}