dim 0.1.4

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

dim

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

使用之前注意事项

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

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

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

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

android 端配置你的项目中,android 目录app下面的 AndroidManifest.xml,内容参考这里

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.coinseast">

    <!-- The INTERNET permission is required for development. Specifically,
         flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_LOGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="coins_east"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <!-- 【必须】消息收发service -->
        <service
            android:name="com.tencent.qalsdk.service.QalService"
            android:exported="true"
            android:process=":QALSERVICE" >
        </service>
        <service
            android:name="com.tencent.qalsdk.service.QalAssistService"
            android:exported="false"
            android:process=":QALSERVICE" >
        </service>

        <!-- 【必须】 离线消息广播接收器 -->
        <receiver
            android:name="com.tencent.qalsdk.QALBroadcastReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="com.tencent.qalsdk.broadcast.qal" />
            </intent-filter>
        </receiver>
        <receiver
            android:name="com.tencent.qalsdk.core.NetConnInfoCenter" android:process=":QALSERVICE">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.TIME_SET" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.TIMEZONE_CHANGED" />
            </intent-filter>

            <!-- ImSDK 3.0.2 后添加 -->
            <intent-filter>
                <action android:name="com.tencent.qalsdk.service.TASK_REMOVED" />
            </intent-filter>
        </receiver>
    </application>
</manifest>

ios端配置:

因为git上传文件必须要小于100m的限制,所以云im有些framework上传不了,因此需要开发者自己到这里下载

下载好了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_lock<std::__1::mutex>::unlock() in ImSDK(task_queue.o)
             "_uncompress", referenced from:

这说明你本地的一些库没有引用,用xcode打开你的ios工程,然后参考这里 这里如何集成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、发送文本消息

0.0.1

  • TODO: Describe initial release.

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: () {
                  postData();
                },
                child: Text('测试发送数据'),
              ),
              RaisedButton(
                onPressed: () {
                  canCelListener();
                },
                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(1400001533, "18681446372", "sfesfs");
//      var result = await _dim.postDataTest();
      print(result);
    } on PlatformException {
      print("登录  失败");
    }
  }

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

Use this package as a library

1. Depend on it

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


dependencies:
  dim: ^0.1.4

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.4 Aug 28, 2018 Go to the documentation of dim 0.1.4 Download dim 0.1.4 archive
0.1.3 Aug 25, 2018 Go to the documentation of dim 0.1.3 Download dim 0.1.3 archive
0.1.2 Aug 6, 2018 Go to the documentation of dim 0.1.2 Download dim 0.1.2 archive
0.1.1 Aug 6, 2018 Go to the documentation of dim 0.1.1 Download dim 0.1.1 archive
0.1.0 Aug 6, 2018 Go to the documentation of dim 0.1.0 Download dim 0.1.0 archive
0.0.4 Aug 6, 2018 Go to the documentation of dim 0.0.4 Download dim 0.0.4 archive
0.0.3 Aug 6, 2018 Go to the documentation of dim 0.0.3 Download dim 0.0.3 archive
0.0.2 Aug 6, 2018 Go to the documentation of dim 0.0.2 Download dim 0.0.2 archive
0.0.1 Aug 6, 2018 Go to the documentation of dim 0.0.1 Download dim 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
35
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/manger.dart.

Run flutter format to format lib/manger.dart.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

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