dim 0.1.19

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 42

dim

封装的一个腾讯云im,以便于flutter开发者可以方便继承im到自己的应用中

使用之前注意事项

开发者需要到腾讯云上申请一个appid,申请地址

申请成功之后,平台会分配一个appid给到开发者。

1、sig的获取,sig一般就是开发者自己的后台开发同学提供,可以参考腾讯云文档实现sig申请。

2、都准备ok了,就可以登录imsdk了。

登录代码参考这里:

  Future<void> login() async {
    try {
//      var result = await _dim.imLogin(1400117017, "rq3",
//          "eJxlz11PwjAUgOH7-YpmtxjTj32AdwuCMIcGJkq9WWbXlkbsSul0avjvhkniEs-t856cnG8PAOA-ZPllyVjdaFe4T8N9cAV86F-8oTGqKkpXEFv9Q94aZXlRCsdthygMQwxhv1EV104JdS7snvTwUL0W3YXf7QBChGKI4n6iZIeLCR3Pl9dGrMUwj1iyqvSNXNMmmyU5HQ6mVjwumjs5truYbkcbTeR8m6RCRLssu0*pfVrepvmgbdhzFr1MP7gLZ-ir3qxkPGlZsB-1Tjr1xs-vBBBHJA5wT9*5PahadwGGKESYwNP43tH7ARZeXFI_");
      var result = await _dim.imLogin(1400117017, "rq2",
          "eJxlz01Pg0AQgOE7v4Ls2ejMwnaxSQ9Sq60W09o2QS*ElKGsHxS2SxGM-92ITSRxrs87mcynZds2W89X5-F2u69yE5mmIGYPbQbs7A*LQiVRbCJHJ-*QPgqlKYpTQ7pDFEJwgH6jEsqNStWp0CXv4SF5jboLv9suAKIElP1E7ToMJsvx7HpuKGhhJ1J3WU-Tl0E1fp6oMPPC9SNlOHiqFhftBmdhvLhSvi-L*yn4spG5vinfNGUplu2x8bmHCbmeaaugvn248zb1aNQ7adQ7nd5xgaO8dLyeHkkf1D7vAg4okDvwM8z6sr4BAlVcKw__");
      print(result);
    } on PlatformException {
      print("登录  失败");
    }
  }
ios端配置:
 
因为git上传文件必须要小于100m的限制,所以云im有些framework上传不了,因此需要开发者自己到[这里下载](http://dldir1.qq.com/hudongzhibo/im/IM_iOS_SDK_3.3.2.zip)。

下载好了zip包之后,把里面的这些framework copy到 `/Users/xxx/.pub-cache/hosted/pub.dartlang.org/dim-0.x.x/ios`
目录下(注意,运行fetch_libs.sh获取所有的framework).

随后到你的工程的ios文件夹中执行 `pod install`

然后就可以跑起来了。

如果不可以跑起来,报了这样的错误。

Undefined symbols for architecture x86_64: "operator new[](unsigned long, std::nothrow_t const&)", referenced from: openbdh::BdhUpTransaction::initSegmentList() in ImSDK(bdhUpTransaction.o) openbdh::BdhUpTransaction::getData(openbdh::DataTransInfo*) in ImSDK(bdhUpTransaction.o) "std::__1::__throw_system_error(int, char const*)", referenced from: std::__1::unique_lockstd::__1::mutex::unlock() in ImSDK(task_queue.o) "_uncompress", referenced from:


这说明你本地的一些库没有引用,用xcode打开你的ios工程,然后[参考这里](https://cloud.tencent.com/document/product/269/9147)
这里如何集成IMSDK写的很清楚,需要依赖系统的那些库。


注意:

1、引入的时候搜索你会发现.dylib现在变为了.tbd了。还有就是IOS模拟器跑不了,腾讯云没有提供X86的framework。
2、注意不要引入IMUGCExt.framework,TXRTMPSDK.framework。
3、注意,当你升级dim之后,cache对应的版本中没有这些库了,因此要在copy一份过去,可以直接从你之前的版本中copy,在到ios工程下执行`pod install`。

## 已有的功能

1、登录

2、登出

3、获取会话列表

4、删除一个会话

5、获取会话消息

6、发送图片消息

7、发送文本消息

8、发送地理位置消息

0.1.19

获取用户个人资料

0.1.16

简化dim的使用,android端不在需要在AndroidManifests.xml文件中配置service等内容,全部交给插件处理。

0.1.13

  • 归一化错误码

0.1.11

  • 去掉无用api,解决消息重复的问题,定位到是重复登录注册了多次listener,做了容错处理。

0.1.8

  • 解决了消息解析不出的问题。

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:dim/dim.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Dim _dim = new Dim();
  String _platformVersion = 'Unknown';

  StreamSubscription<dynamic> _messageStreamSubscription;

  @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.
    try {
      platformVersion = await _dim.platformVersion;
    } 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;

    if (_messageStreamSubscription == null) {
      _messageStreamSubscription = _dim.onMessage.listen((dynamic onData) {
        print("我监听到数据了$onData");
      });
    }

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    //flutter 这里应该页面退出栈会调用,但是如果这个是根页面,日志是打不出来的。
    canCelListener();
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: new Column(
            children: <Widget>[
              new Text('Running on: $_platformVersion\n'),
              RaisedButton(
                onPressed: () {
                  login();
                },
                child: Text('登录imsdk'),
              ),
              RaisedButton(
                onPressed: () {
                  logout();
                },
                child: Text('登出imsdk'),
              ),
              RaisedButton(
                onPressed: () {
                  postData();
                },
                child: Text('测试发送数据'),
              ),
              RaisedButton(
                onPressed: () {
                  canCelListener();
                },
                child: Text('取消监听'),
              ),
              RaisedButton(
                onPressed: () {
                  sendTextMsg();
                },
                child: Text('发送文本消息'),
              ),
              RaisedButton(
                onPressed: () {
                  sendImageMsg();
                },
                child: Text('发送图片消息'),
              ),
              RaisedButton(
                onPressed: () {
                  sendLocationMsg();
                },
                child: Text('发送位置消息'),
              ),
              RaisedButton(
                onPressed: () {
                  getMessages();
                },
                child: Text('拿到历史消息'),
              ),
              RaisedButton(
                onPressed: () {
                  getUserInfo();
                },
                child: Text('获取个人资料'),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<void> postData() async {
    try {
      var result = await _dim.postDataTest();
      print(result);
    } on PlatformException {
      print("listen  失败");
    }
  }

//  Future<void> login() async {
//    try {
//      var result = await _dim.imLogin(1400119955, "18681446372", "eJxlz11PwjAUgOH7-YpmtxjTj32AdwuCMIcGJkq9WWbXlkbsSul0avjvhkniEs-t856cnG8PAOA-ZPllyVjdaFe4T8N9cAV86F-8oTGqKkpXEFv9Q94aZXlRCsdthygMQwxhv1EV104JdS7snvTwUL0W3YXf7QBChGKI4n6iZIeLCR3Pl9dGrMUwj1iyqvSNXNMmmyU5HQ6mVjwumjs5truYbkcbTeR8m6RCRLssu0*pfVrepvmgbdhzFr1MP7gLZ-ir3qxkPGlZsB-1Tjr1xs-vBBBHJA5wT9*5PahadwGGKESYwNP43tH7ARZeXFI_");
////      var result = await _dim.postDataTest();
//      print(result);
//    } on PlatformException {
//      print("登录  失败");
//    }
//  }

  Future<void> sendTextMsg() async {
    try {
      var result = await _dim.sendTextMessages("rq2", "haahah");
      print(result);
    } on PlatformException {
      print("发送消息失败");
    }
  }

  Future<void> sendImageMsg() async {
    try {
      var result = await _dim.sendImageMessages("rq2", "tyyhuiijkoi.png");
      print(result);
    } on PlatformException {
      print("发送图片消息失败");
    }
  }

  Future<void> sendLocationMsg() async {
    try {
      var result =
          await _dim.sendLocationMessages("rq2", 113.93, 22.54, "腾讯大厦");
      print(result);
    } on PlatformException {
      print("发送位置消息失败");
    }
  }

  Future<void> login() async {
    try {
//      var result = await _dim.imLogin(1400117017, "rq3",
//          "eJxlz11PwjAUgOH7-YpmtxjTj32AdwuCMIcGJkq9WWbXlkbsSul0avjvhkniEs-t856cnG8PAOA-ZPllyVjdaFe4T8N9cAV86F-8oTGqKkpXEFv9Q94aZXlRCsdthygMQwxhv1EV104JdS7snvTwUL0W3YXf7QBChGKI4n6iZIeLCR3Pl9dGrMUwj1iyqvSNXNMmmyU5HQ6mVjwumjs5truYbkcbTeR8m6RCRLssu0*pfVrepvmgbdhzFr1MP7gLZ-ir3qxkPGlZsB-1Tjr1xs-vBBBHJA5wT9*5PahadwGGKESYwNP43tH7ARZeXFI_");
      var result = await _dim.imLogin(1400117017, "rq2",
          "eJxlz01Pg0AQgOE7v4Ls2ejMwnaxSQ9Sq60W09o2QS*ElKGsHxS2SxGM-92ITSRxrs87mcynZds2W89X5-F2u69yE5mmIGYPbQbs7A*LQiVRbCJHJ-*QPgqlKYpTQ7pDFEJwgH6jEsqNStWp0CXv4SF5jboLv9suAKIElP1E7ToMJsvx7HpuKGhhJ1J3WU-Tl0E1fp6oMPPC9SNlOHiqFhftBmdhvLhSvi-L*yn4spG5vinfNGUplu2x8bmHCbmeaaugvn248zb1aNQ7adQ7nd5xgaO8dLyeHkkf1D7vAg4okDvwM8z6sr4BAlVcKw__");
      print(result);
    } on PlatformException {
      print("登录  失败");
    }
  }

  Future<void> logout() async {
    try {
      var result = await _dim.imLogout();
      print(result);
    } on PlatformException {
      print("登出  失败");
    }
  }

  Future<dynamic> getMessages() async {
    try {
      var result = await _dim.getMessages(
        "rq3",
      );
      print(result);
    } on PlatformException {}
  }

  void canCelListener() {
    if (_messageStreamSubscription != null) {
      _messageStreamSubscription.cancel();
    }
  }

  void getUserInfo() async {
    try {
      List<String> users = List();
      users.add("jiumi_1");
      var result = await _dim.getUsersProfile(users);
      print(result);
    } on PlatformException {
      print("获取个人资料失败");
    }
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  dim: ^0.1.19

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:dim/dim.dart';
  
Version Uploaded Documentation Archive
0.1.19 Nov 13, 2018 Go to the documentation of dim 0.1.19 Download dim 0.1.19 archive
0.1.18 Nov 5, 2018 Go to the documentation of dim 0.1.18 Download dim 0.1.18 archive
0.1.17 Nov 5, 2018 Go to the documentation of dim 0.1.17 Download dim 0.1.17 archive
0.1.16 Nov 5, 2018 Go to the documentation of dim 0.1.16 Download dim 0.1.16 archive
0.1.15 Nov 5, 2018 Go to the documentation of dim 0.1.15 Download dim 0.1.15 archive
0.1.14 Nov 5, 2018 Go to the documentation of dim 0.1.14 Download dim 0.1.14 archive
0.1.13 Nov 1, 2018 Go to the documentation of dim 0.1.13 Download dim 0.1.13 archive
0.1.12 Oct 30, 2018 Go to the documentation of dim 0.1.12 Download dim 0.1.12 archive
0.1.11 Oct 30, 2018 Go to the documentation of dim 0.1.11 Download dim 0.1.11 archive
0.1.10 Oct 30, 2018 Go to the documentation of dim 0.1.10 Download dim 0.1.10 archive

All 24 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
42
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest stable Dart SDK in pubspec.yaml. (-20 points)

The SDK constraint in pubspec.yaml doesn't allow the latest stable Dart SDK release.

The description contains too many non-ASCII characters. (-20 points)

The site uses English as it's primary language. Please use a description that primarily contains characters used when writing English.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 < 2.2.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8