flutter_phone 0.0.28 copy "flutter_phone: ^0.0.28" to clipboard
flutter_phone: ^0.0.28 copied to clipboard

Flutter plugin for phone call,phone logs,phone,audio.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_phone/flutter_phone.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 _phone = FlutterPhone();

  @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 _phone.getPlatformVersion() ?? 'Unknown platform version';
      //
      // var res = _phone.permission();
      // print("res");
      // print(res);

      await _phone.permission();
      // var res = await _phone.getSim();
      // print("res:fluter:sim:");
      // print(res);

      // _phone.toCall({"phone":"13578021300","id":0});

      //获取通话记录和录音&&上传
      String url = "http://192.168.110.14:9514"; //此处自行替换: 接口地址
      String _t = "c0bdec3058b764123eded047df14cb38"; //此处自行替换: token


      String identification = "4d507500cc7a5398";  //此处自行替换: 设备id
      String env = "prod"; //此处自行替换(录音文件存储目录:prod:正式 test:测试 dev:开发)
      int day = 50; //同步*天数据

      Map map = {
        // 通用设置
        "_t": _t,
        "domain": url, //此处自行替换
        "endpoint": "https://oss-cn-beijing.aliyuncs.com", //oss区域对应域名(固定)
        "bucketName": "kingchem", //bucketName(固定)
        "identification": identification, //此处替换
        "stsServer": "/api/audio/securityToken", //获取oss鉴权信息(域名+接口地址+当前登录token)

        // 通话录音
        "time": 86400 * day * 1000, //通话录音-时间范围
        "dir": 'dtms/$env/audio/$identification/', //通话录音-录音文件上传目录
        "uploadAlways": 0, //通话录音-(未实现)缓存是否已上传录音文件:0是,1不
        "logsCat": "[call,audio,match]", //日志显示分类
        "callCnfServer": "/api/audio/callCnf", //通话录音-用户配置信息(未实现)
        "callSaveServer": "/mobile/call/saveLog", //通话录音-通话记录上传
        "audioStatusServer": "/mobile/call/noticeUpload", //通话录音-更新录音状态接口
        "audioFileUploadServer": "/mobile/call/audioFileUpload", //通话录音-原始录音文件信息保存
      };
      _phone.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: Column(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              Text('Running on: $_platformVersion\n',textAlign: TextAlign.center,),
              TextButton(
                onPressed: initPlatformState,
                child: Text("同步通话录音"),
                style: ButtonStyle(
                  textStyle: MaterialStateProperty.all(TextStyle(fontSize: 18)),
                  padding: MaterialStateProperty.all(EdgeInsets.all(10)),
                  backgroundColor: MaterialStateProperty.all(Colors.red),
                  foregroundColor: MaterialStateProperty.all(Colors.amberAccent)
                ),
              )
            ],
          ),
        )
      ),
    );

    /*
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Container(
          color: Colors.amberAccent,
          alignment: Alignment(0.0,0.0),
          child: new Container(
            child: Text('Running on: $_platformVersion\n',textAlign: TextAlign.center,),
          ),
        ),
      ),
    );
     */
  }
}
0
likes
0
points
147
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for phone call,phone logs,phone,audio.

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_phone

Packages that implement flutter_phone