Git Product home page Git Product logo

dim's Introduction

dim

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

使用之前注意事项

如果你之前没有使用过腾讯云,请仔细阅读这段文字,如果你已经对腾讯云im了如指掌,可以越过,但建议还是熟悉以下。

因为这个库是基于腾讯云im的,因此需要去云im申请一个应用,阅读这篇文章可以获得以下知识:

1、appid怎么来的

2、账号及其对应的sig如何来的,已经推荐的sig的生成方式(当然这个是后台同学关注的)。

弄清楚这些之后,就可以开始使用dim了。

使用 dim

dim的使用非常简单,只需引入这个库就可以使用了。

dependencies:
  dim: ^0.2.6

不需要像我之前实现的版本那样进行一些繁琐的配置,因为云im升级之后,支持maven以及pod的引用方式啦。那么Android端

Android端需要注意什么?

1、混淆配置,在你的flutter的Android工程中配置混淆。

-keep class com.tencent.** { *; }

IOS端需要注意什么?

1、请注意在你的flutter工程的ios项目根目录执行pod update[非必须,如果报错建议执行一次]

2、随后在执行一次pod install

demo截图

截图

构建

已有的功能

  1. 初始化

    建议整个应用生命周期只执行一次。

  2. 登录

  3. 登出

  4. 获取会话列表

  5. 删除一个会话

  6. 获取私信会话消息[群聊消息目前没有封装]

    注意,私信发送方的资料云im改成了异步的方式,因此,这个版本不在返回! 建议用户自己查询一次,最好的方式是将用户资料存储在本地db中,并

  7. 发送图片消息

    注意,图片消息中图片云im需要的是图片的本地路径

  8. 发送文本消息

  9. 发送地理位置消息

  10. 获取用户资料

  11. 设置用户资料

    目前仅仅提供了设置nickgenderfaceUrl,有需要在补充。

  12. 监听新的消息

  13. 监听有新的会话

    注意,和新的消息是一个消息通道,只不过收到的内容是`[]`,对一个空的数组,此时需要去主动调用4获取会话列表来查最新会话列表
    
  14. 发送语音消息,基本和图片消息一致,使用本地路径

注意

demo中的 initListener 中的逻辑需要调用一下,最好是在initState中,建立消息通道,flutter这边才能收发消息。

todo

根据需要,可以提issue,或者接受pr来实现更多的接口,主要是体力活。

dim's People

Contributors

brzhang666 avatar joshuaton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dim's Issues

DIM引用到自己项目,AndroidManifest报错

D:\yfw-enterprise-flutter\android\app\src\debug\AndroidManifest.xml:18:9-31 Error:
Attribute application@label value=(孷�����ҵ��) from AndroidManifest.xml:18:9-31
is also present at [com.tencent.imsdk:imsdk:4.5.15] AndroidManifest.xml:18:9-41 value=(@string/app_name).
Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:9:5-19:19 to override.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processDebugManifest'.

Manifest merger failed with multiple errors, see logs

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

发现demo登录不进去,之前是可以登录的,然后我发现我自己项目登录的时候报如下错误

E/AndroidRuntime(15221): FATAL EXCEPTION: main
E/AndroidRuntime(15221): Process: com.wkmill.androidapp, PID: 15221
E/AndroidRuntime(15221): java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.EventChannel$EventSink.success(java.lang.Object)' on a null object reference
E/AndroidRuntime(15221): at com.brzhang.flutter.dim.DimPlugin$2.onRefresh(DimPlugin.java:86)
E/AndroidRuntime(15221): at com.tencent.imsdk.conversation.ConversationManager$1$3.run(ConversationManager.java:280)
E/AndroidRuntime(15221): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime(15221): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(15221): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(15221): at android.app.ActivityThread.main(ActivityThread.java:5318)
E/AndroidRuntime(15221): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(15221): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(15221): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:922)
E/AndroidRuntime(15221): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:717)

flutter build apk 报错

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project 'dim'.

Could not resolve all files for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.1.2.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.1.2.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> Connect to 127.0.0.1:12759 [/127.0.0.1] failed: Connection refused (Connection refused)
> Could not resolve com.android.tools.build:gradle:3.1.2.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.2/gradle-3.1.2.pom'.
> Connect to 127.0.0.1:12759 [/127.0.0.1] failed: Connection refused (Connection refused)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 0s

The plugin dim could not be built due to the issue above.

報錯DIM

Multiple commands produce '/Users/wilson/flutterProject/XX/build/ios/Debug-iphonesimulator/dim/dim.framework/Info.plist':

demo 跑不起来 ios13模拟器

Launching lib/main.dart on iPhone 11 in debug mode...
Running pod install...
CocoaPods' output:

Preparing

Analyzing dependencies

Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

Finding Podfile changes
  - Flutter
  - dim

Fetching external sources
-> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
-> Fetching podspec for `dim` from `.symlinks/plugins/dim/ios`

Resolving dependencies of `Podfile`
  CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
[!] CocoaPods could not find compatible versions for pod "TXIMSDK_iOS":
  In snapshot (Podfile.lock):
    TXIMSDK_iOS (= 4.3.135)

  In Podfile:
    dim (from `.symlinks/plugins/dim/ios`) was resolved to 0.2.7, which depends on
      TXIMSDK_iOS


You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `TXIMSDK_iOS` inside your development pod `dim`.
   You should run `pod update TXIMSDK_iOS` to apply changes you've made.

/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:257:in `process_topmost_state'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/resolver.rb:94:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:986:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:984:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:410:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:234:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:233:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:156:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.8.4/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'

Error output from CocoaPods:

[!] Automatically assigning platform `iOS` with version `12.1` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.
To update the CocoaPods specs, run:
pod repo update

Error running pod install
Error launching application on iPhone 11.

Add Desktop and Web support

Flutter for web 与 MacOS已经进入Beta阶段,在Flutter应用中打通三端通信成为必备(当前我已有Web和APP端实现的需求)
对此期望能增加Desktop与Web端的支持

  • 支持Window OS
  • 支持Mac OS
  • 支持Web(优先)

可以正常的C2C发送文本消息,但无法发送图片消息爆出如下错误

[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)
• Flutter version 1.7.8+hotfix.4 at /Users/speanut/development/flutter
• Framework revision 20e59316b8 (7 weeks ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/speanut/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.3

[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 38.2.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (1 available)
• iPhone 8 • 5824B4F7-8559-4598-A6A5-DE6CDEF331D2 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)

• No issues found!

爆出如下的错误

flutter: send message failed. code: -3 desc:Fetch token failed: http request failed

在发送图片之前,测试 可正常发送文本消息
查阅官方文档发现没有-3的错误码 用example测试发送图片 也是报错 问问作者大佬能提供解决的方案吗

运行你的demo报错了,说什么应用名称不一致

Launching lib\demo\dim_demo\main.dart on Note9 in debug mode...
C:\Users\M\Desktop\Code\flutter_study\android\app\src\debug\AndroidManifest.xml:11:9-38 Error:
Attribute application@label value=(flutter_study) from AndroidManifest.xml:11:9-38
is also present at [com.tencent.imsdk:imsdk:4.3.145] AndroidManifest.xml:18:9-41 value=(@string/app_name).
Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:9:5-33:19 to override.
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

通过获取历史消息记录的api,获取到的消息没有发送时间的字段?

[{"message":{"longitude":22.539999999999999,"latitude":113.93000000000001,"desc":"腾讯大厦"},"timConversation":{"type":1,"peer":"hoolly1"},"sender":"hoolly3"},{"message":{"longitude":22.539999999999999,"latitude":113.93000000000001,"desc":"腾讯大厦"},"timConversation":{"type":1,"peer":"hoolly1"},"sender":"hoolly3"},{"message":{"text":"haahah"},"timConversation":{"type":1,"peer":"hoolly1"},"sender":"hoolly3"}]

如上消息内容,没有发送时间,接收时间等,那么在消息列表里该如何排序显示呢?

集成后安卓 打包报错

`* What went wrong:
Execution failed for task ':dim:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\Administrator.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84318244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.

 C:\Users\Administrator\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84318244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 33s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 34.2s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin dim...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 1.1s

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project 'dim'.

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 0s

The plugin dim could not be built due to the issue above.
`

非常好

dim按照readme文件操作pod update && pod install 报错

[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)
• Flutter version 1.7.8+hotfix.3 at /Users/speanut/development/flutter
• Framework revision b712a172f9 (7 weeks ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/speanut/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.3

[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4

[!] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (2 available)
• speanut (2) • 925d906d24fc7bfc700785e65ca0a0da59662cd8 • ios • iOS 12.3
• iPhone 8 • 5824B4F7-8559-4598-A6A5-DE6CDEF331D2 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-12-2 (simulator)

error: Multiple commands produce '/build/ios/Debug-iphonesimulator/dim/dim.framework/Info.plist':
1) Target 'dim' (project 'Pods') has copy command from '/Users/speanut/development/flutter/.pub-cache/hosted/pub.flutter-io.cn/dim-0.2.6/ios/Classes/MJExtension/Info.plist' to '/build/ios/Debug-iphonesimulator/dim/dim.framework/Info.plist'
2) Target 'dim' (project 'Pods') has process command with output '/build/ios/Debug-iphonesimulator/dim/dim.framework/Info.plist'
Runner-cgasymwulsayopauzwnivtcygwgd
note: Using new build systemnote: Planning buildnote: Constructing build description

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.