├── android ├── settings.gradle ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── io │ │ │ └── openim │ │ │ └── flutter_openim_sdk │ │ │ ├── listener │ │ │ ├── OnCustomBusinessListener.java │ │ │ ├── OnUploadLogsListener.java │ │ │ ├── OnUserListener.java │ │ │ ├── OnListenerForService.java │ │ │ ├── OnConnListener.java │ │ │ ├── OnBaseListener.java │ │ │ ├── OnMsgSendListener.java │ │ │ ├── OnFriendshipListener.java │ │ │ ├── OnConversationListener.java │ │ │ ├── OnGroupListener.java │ │ │ ├── OnAdvancedMsgListener.java │ │ │ └── OnUploadFileListener.java │ │ │ ├── util │ │ │ ├── JsonUtil.java │ │ │ └── CommonUtil.java │ │ │ ├── manager │ │ │ ├── BaseManager.java │ │ │ ├── UserManager.java │ │ │ ├── IMManager.java │ │ │ ├── FriendshipManager.java │ │ │ └── ConversationManager.java │ │ │ ├── connectivity │ │ │ ├── VisibilityListener.java │ │ │ ├── Connectivity.java │ │ │ └── ConnectivityListener.java │ │ │ └── FlutterOpenimSdkPlugin.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── flutter_openim_sdk │ │ └── FlutterOpenimSdkPluginTest.java └── build.gradle ├── .idea ├── .gitignore ├── vcs.xml ├── libraries │ ├── Flutter_Plugins.xml │ └── Dart_SDK.xml ├── misc.xml ├── modules.xml └── flutter_openim_sdk.iml ├── example ├── ios │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-50x50@1x.png │ │ │ │ ├── Icon-App-50x50@2x.png │ │ │ │ ├── Icon-App-57x57@1x.png │ │ │ │ ├── Icon-App-57x57@2x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-72x72@1x.png │ │ │ │ ├── Icon-App-72x72@2x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── RunnerTests │ │ └── RunnerTests.swift │ ├── .gitignore │ ├── Podfile.lock │ └── Podfile ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ ├── java │ │ │ │ │ └── io │ │ │ │ │ │ └── openim │ │ │ │ │ │ └── flutter_openim_sdk_example │ │ │ │ │ │ └── MainActivity.java │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle.kts │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── build.gradle.kts │ └── settings.gradle.kts ├── README.md ├── .gitignore ├── test │ └── widget_test.dart ├── lib │ └── main.dart ├── analysis_options.yaml ├── .metadata └── pubspec.yaml ├── .gitignore ├── lib ├── .DS_Store ├── src │ ├── enum │ │ ├── allow_type.dart │ │ ├── relationship.dart │ │ ├── join_source.dart │ │ ├── login_status.dart │ │ ├── receive_message_opt.dart │ │ ├── group_status.dart │ │ ├── group_type.dart │ │ ├── group_role_level.dart │ │ ├── group_member_filter.dart │ │ ├── conversation_type.dart │ │ ├── im_platform.dart │ │ ├── group_verification.dart │ │ ├── group_at_type.dart │ │ ├── message_status.dart │ │ ├── listener_type.dart │ │ ├── message_type.dart │ │ └── sdk_error_code.dart │ ├── logger.dart │ ├── listener │ │ ├── custom_business_listener.dart │ │ ├── msg_send_progress_listener.dart │ │ ├── user_listener.dart │ │ ├── listener_for_service.dart │ │ ├── connect_listener.dart │ │ ├── advanced_msg_listener.dart │ │ ├── conversation_listener.dart │ │ ├── upload_file_listener.dart │ │ ├── friendship_listener.dart │ │ └── group_listener.dart │ ├── openim.dart │ ├── models │ │ ├── input_status_changed_data.dart │ │ ├── set_group_member_info.dart │ │ ├── init_config.dart │ │ ├── update_req.dart │ │ ├── search_info.dart │ │ └── conversation_info.dart │ ├── utils.dart │ └── manager │ │ └── im_user_manager.dart └── flutter_openim_sdk.dart ├── ios ├── Classes │ ├── FlutterOpenimSdkPlugin.h │ ├── Util │ │ ├── Any+Extension.swift │ │ └── FlutterMethodCall+Extension.swift │ ├── CommonUtil.swift │ ├── BaseCallback.swift │ ├── FlutterOpenimSdkPlugin.m │ ├── JsonUtil.swift │ ├── Module │ │ ├── BaseServiceManager.swift │ │ └── UserManager.swift │ └── SwiftFlutterOpenimSdkPlugin.swift ├── Resources │ └── PrivacyInfo.xcprivacy └── flutter_openim_sdk.podspec ├── test └── flutter_openim_sdk_test.dart ├── .github ├── workflows │ ├── stale.yml │ └── issue-translator.yml └── ISSUE_TEMPLATE │ ├── feature-request.md │ └── bug-report.md ├── flutter_openim_sdk.iml ├── README.zh-cn.md ├── pubspec.yaml └── pubspec.lock /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_openim_sdk' 2 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #.DS_Store 2 | #/.packages 3 | #/.dart_tool 4 | #/example/ios/Podfile.lock 5 | -------------------------------------------------------------------------------- /lib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/lib/.DS_Store -------------------------------------------------------------------------------- /lib/src/enum/allow_type.dart: -------------------------------------------------------------------------------- 1 | class AllowType { 2 | static const allow = 0; 3 | static const notAllow = 1; 4 | } -------------------------------------------------------------------------------- /lib/src/enum/relationship.dart: -------------------------------------------------------------------------------- 1 | class AllowType { 2 | static const black = 0; 3 | static const friend = 1; 4 | } -------------------------------------------------------------------------------- /ios/Classes/FlutterOpenimSdkPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FlutterOpenimSdkPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /lib/src/enum/join_source.dart: -------------------------------------------------------------------------------- 1 | class JoinSource { 2 | static const invited = 2; 3 | static const search = 3; 4 | static const QRCode = 4; 5 | } -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /lib/src/enum/login_status.dart: -------------------------------------------------------------------------------- 1 | class LoginStatus { 2 | static const logout = 1; 3 | static const logging = 2; 4 | static const logged = 3; 5 | } 6 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .cxx 10 | -------------------------------------------------------------------------------- /test/flutter_openim_sdk_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | void main() { 4 | TestWidgetsFlutterBinding.ensureInitialized(); 5 | } 6 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /lib/src/enum/receive_message_opt.dart: -------------------------------------------------------------------------------- 1 | class ReceiveMessageOpt { 2 | static const receive = 0; 3 | static const notReceive = 1; 4 | static const notNotify = 2; 5 | } -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /lib/src/enum/group_status.dart: -------------------------------------------------------------------------------- 1 | /// Group Status 2 | class GroupStatus { 3 | static const normal = 0; 4 | static const baned = 1; 5 | static const dismissed = 2; 6 | static const muted = 3; 7 | } 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openimsdk/open-im-sdk-flutter/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/src/logger.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | 3 | /// print full log 4 | class Logger { 5 | // Sample of abstract logging function 6 | static void print(String text) { 7 | log('** $text', name: 'flutter_openim_sdk'); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/src/enum/group_type.dart: -------------------------------------------------------------------------------- 1 | /// Group Types 2 | class GroupType { 3 | /// General group (Deprecated in v3) 4 | @Deprecated('Use work instead') 5 | static const int general = 0; 6 | 7 | /// Work group 8 | static const int work = 2; 9 | } 10 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/io/openim/flutter_openim_sdk_example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk_example; 2 | 3 | import io.flutter.embedding.android.FlutterActivity; 4 | 5 | public class MainActivity extends FlutterActivity { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip 6 | -------------------------------------------------------------------------------- /lib/src/enum/group_role_level.dart: -------------------------------------------------------------------------------- 1 | /// Group Member Roles 2 | class GroupRoleLevel { 3 | /// Group owner 4 | static const owner = 100; 5 | 6 | /// Administrator 7 | static const admin = 60; 8 | 9 | /// Regular member 10 | static const member = 20; 11 | } 12 | -------------------------------------------------------------------------------- /.idea/libraries/Flutter_Plugins.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/enum/group_member_filter.dart: -------------------------------------------------------------------------------- 1 | /// Group Member Filter 2 | class GroupMemberFilter { 3 | static const all = 0; 4 | 5 | static const owner = 1; 6 | 7 | static const admin = 2; 8 | 9 | static const member = 3; 10 | 11 | static const adminAndMember = 4; 12 | 13 | static const superAndAdmin = 4; 14 | } 15 | -------------------------------------------------------------------------------- /lib/src/listener/custom_business_listener.dart: -------------------------------------------------------------------------------- 1 | class OnCustomBusinessListener { 2 | Function(String s)? onRecvCustomBusinessMessage; 3 | 4 | OnCustomBusinessListener({this.onRecvCustomBusinessMessage}); 5 | 6 | void recvCustomBusinessMessage(String s) { 7 | onRecvCustomBusinessMessage?.call(s); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | .cxx/ 9 | 10 | # Remember to never publicly share your keystore. 11 | # See https://flutter.dev/to/reference-keystore 12 | key.properties 13 | **/*.keystore 14 | **/*.jks 15 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/openim.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 3 | 4 | class OpenIM { 5 | static const version = '3.8.3+hotfix.10.1'; 6 | 7 | static const _channel = MethodChannel('flutter_openim_sdk'); 8 | 9 | static final iMManager = IMManager(_channel); 10 | 11 | OpenIM._(); 12 | } 13 | -------------------------------------------------------------------------------- /example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/enum/conversation_type.dart: -------------------------------------------------------------------------------- 1 | /// Conversation types 2 | class ConversationType { 3 | /// Single chat 4 | static const single = 1; 5 | 6 | /// Group (Deprecated in v3) 7 | @Deprecated('Use superGroup instead') 8 | static const group = 2; 9 | 10 | /// Super group chat 11 | static const superGroup = 3; 12 | 13 | /// Notification 14 | static const notification = 4; 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /lib/src/listener/msg_send_progress_listener.dart: -------------------------------------------------------------------------------- 1 | /// Message Sending Progress Listener 2 | class OnMsgSendProgressListener { 3 | Function(String clientMsgID, int progress)? onProgress; 4 | 5 | OnMsgSendProgressListener({this.onProgress}); 6 | 7 | /// Message sending progress 8 | void progress(String clientMsgID, int progress) { 9 | onProgress?.call(clientMsgID, progress); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/src/enum/im_platform.dart: -------------------------------------------------------------------------------- 1 | /// The current Flutter platform supports only Android/iOS 2 | class IMPlatform { 3 | /// iOS 4 | static const ios = 1; 5 | 6 | /// Android 7 | static const android = 2; 8 | 9 | static const windows = 3; 10 | static const xos = 4; 11 | static const web = 5; 12 | static const miniWeb = 6; 13 | static const linux = 7; 14 | static const androidPad = 8; 15 | static const ipad = 9; 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/enum/group_verification.dart: -------------------------------------------------------------------------------- 1 | /// Group Join Verification Settings 2 | class GroupVerification { 3 | /// Apply and invite directly for entry 4 | static const int applyNeedVerificationInviteDirectly = 0; 5 | 6 | /// Everyone needs verification to join, except for group owners and administrators who can invite directly 7 | static const int allNeedVerification = 1; 8 | 9 | /// Directly join the group 10 | static const int directly = 2; 11 | } 12 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | @main 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/enum/group_at_type.dart: -------------------------------------------------------------------------------- 1 | /// Conversation Strong Hint Content 2 | class GroupAtType { 3 | /// Cancel all hints, equivalent to calling the resetConversationGroupAtType method 4 | static const atNormal = 0; 5 | 6 | /// @ me hint 7 | static const atMe = 1; 8 | 9 | /// @ all hint 10 | static const atAll = 2; 11 | 12 | /// @ all and @ me hint 13 | static const atAllAtMe = 3; 14 | 15 | /// Group notification hint 16 | static const groupNotification = 4; 17 | } 18 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnCustomBusinessListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import io.openim.flutter_openim_sdk.util.CommonUtil; 4 | 5 | public class OnCustomBusinessListener implements open_im_sdk_callback.OnCustomBusinessListener { 6 | @Override 7 | public void onRecvCustomBusinessMessage(String s) { 8 | CommonUtil.emitEvent("customBusinessListener", "onRecvCustomBusinessMessage", s); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/src/enum/message_status.dart: -------------------------------------------------------------------------------- 1 | /// Message Send Status 2 | class MessageStatus { 3 | /// Sending 4 | static const sending = 1; 5 | 6 | /// Successfully sent 7 | static const succeeded = 2; 8 | 9 | /// Send failed 10 | static const failed = 3; 11 | 12 | /// Already deleted 13 | static const deleted = 4; 14 | } 15 | 16 | enum GetHistoryViewType { 17 | history(0), 18 | search(1); 19 | 20 | final int rawValue; 21 | 22 | const GetHistoryViewType(this.rawValue); 23 | } 24 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Classes/Util/Any+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Any+Extension.swift 3 | // flutter_openim_sdk 4 | // 5 | // Created by willem on 2021/10/9. 6 | // 7 | 8 | import Foundation 9 | 10 | public func typeName(_ obj: Any) -> String { 11 | if obj is AnyClass { 12 | return "\(obj)" 13 | } 14 | return "\(type(of: obj))" 15 | } 16 | 17 | public func safeMainAsync(_ work: @escaping @convention(block) () -> Void) { 18 | if Thread.isMainThread { 19 | work() 20 | } else { 21 | DispatchQueue.main.async(execute: work) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get() 9 | rootProject.layout.buildDirectory.value(newBuildDir) 10 | 11 | subprojects { 12 | val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) 13 | project.layout.buildDirectory.value(newSubprojectBuildDir) 14 | } 15 | subprojects { 16 | project.evaluationDependsOn(":app") 17 | } 18 | 19 | tasks.register("clean") { 20 | delete(rootProject.layout.buildDirectory) 21 | } 22 | -------------------------------------------------------------------------------- /ios/Classes/CommonUtil.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | public class CommonUtil { 5 | 6 | public static func emitEvent(channel: FlutterMethodChannel, method: String, type: String, errCode: Int32?, errMsg: String?, data: Any?){ 7 | safeMainAsync { 8 | var res: [String: Any] = [:] 9 | res["type"] = type 10 | res["data"] = data 11 | res["errCode"] = errCode 12 | res["errMsg"] = errMsg 13 | print("native call flutter { method: \(method) type: \(type) }") 14 | channel.invokeMethod(method, arguments: res) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ios/Classes/BaseCallback.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import OpenIMCore 3 | 4 | public class BaseCallback: NSObject, Open_im_sdk_callbackBaseProtocol { 5 | 6 | private let result:FlutterResult 7 | 8 | init(result:@escaping FlutterResult) { 9 | self.result = result 10 | } 11 | 12 | public func onError(_ errCode: Int32, errMsg: String?) { 13 | print("BaseResult: " + errMsg!) 14 | safeMainAsync { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) } 15 | } 16 | 17 | public func onSuccess(_ data: String?) { 18 | safeMainAsync { self.result(data) } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/util/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.util; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class JsonUtil { 6 | public static String toString(Object o) { 7 | if (o == null) return null; 8 | if (o instanceof String) { 9 | StringBuilder buffer = new StringBuilder(); 10 | buffer.append("\""); 11 | buffer.append(o); 12 | buffer.append("\""); 13 | return buffer.toString(); 14 | } 15 | Object obj = JSONObject.wrap(o); 16 | if (null != obj) { 17 | return obj.toString(); 18 | } 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ios/Classes/FlutterOpenimSdkPlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterOpenimSdkPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "flutter_openim_sdk-Swift.h" 9 | #endif 10 | 11 | @implementation FlutterOpenimSdkPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftFlutterOpenimSdkPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /lib/src/listener/user_listener.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 2 | 3 | /// Current User Profile Listener 4 | class OnUserListener { 5 | /// The information of the logged-in user has been updated 6 | Function(UserInfo info)? onSelfInfoUpdated; 7 | Function(UserStatusInfo info)? onUserStatusChanged; 8 | 9 | OnUserListener({this.onSelfInfoUpdated, this.onUserStatusChanged}); 10 | 11 | /// Callback for changes in user's own information 12 | void selfInfoUpdated(UserInfo info) { 13 | onSelfInfoUpdated?.call(info); 14 | } 15 | 16 | /// Callback for changes in user status 17 | void userStatusChanged(UserStatusInfo info) { 18 | onUserStatusChanged?.call(info); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /lib/src/models/input_status_changed_data.dart: -------------------------------------------------------------------------------- 1 | class InputStatusChangedData { 2 | final String userID; 3 | final String conversationID; 4 | final List? platformIDs; 5 | 6 | InputStatusChangedData({ 7 | required this.userID, 8 | required this.conversationID, 9 | this.platformIDs, 10 | }); 11 | 12 | InputStatusChangedData.fromJson(Map json) 13 | : userID = json['userID'], 14 | conversationID = json['conversationID'], 15 | platformIDs = List.from(json['platformIDs'] ?? []); 16 | 17 | Map toJson() { 18 | final data = {}; 19 | data['userID'] = userID; 20 | data['conversationID'] = conversationID; 21 | data['platformIDs'] = platformIDs; 22 | return data; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ios/Resources/PrivacyInfo.xcprivacy: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPrivacyTracking 6 | 7 | NSPrivacyCollectedDataTypes 8 | 9 | NSPrivacyTrackingDomains 10 | 11 | NSPrivacyAccessedAPITypes 12 | 13 | 14 | NSPrivacyAccessedAPIType 15 | NSPrivacyAccessedAPICategoryUserDefaults 16 | NSPrivacyAccessedAPITypeReasons 17 | 18 | CA92.1 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ios/Classes/JsonUtil.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public class JsonUtil { 4 | 5 | public static func toString(object: AnyObject?)->String { 6 | 7 | if object is NSNull { 8 | return "" 9 | } 10 | 11 | if object == nil { 12 | return "" 13 | } 14 | 15 | if object is String{ 16 | let s = object as! String 17 | let b = s.replacingOccurrences(of: "\"", with: "\\\"") 18 | let a = "\"\(b)\"" 19 | return a 20 | } 21 | let data = try? JSONSerialization.data(withJSONObject: object!, options: JSONSerialization.WritingOptions.init(rawValue: 0)) 22 | let jsonStr = NSString(data: data!, encoding: String.Encoding.utf8.rawValue) 23 | return jsonStr! as String 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_openim_sdk (0.0.1): 4 | - Flutter 5 | - OpenIMSDKCore (= 3.8.3-hotfix.10) 6 | - OpenIMSDKCore (3.8.3-hotfix.10) 7 | 8 | DEPENDENCIES: 9 | - Flutter (from `Flutter`) 10 | - flutter_openim_sdk (from `.symlinks/plugins/flutter_openim_sdk/ios`) 11 | 12 | SPEC REPOS: 13 | trunk: 14 | - OpenIMSDKCore 15 | 16 | EXTERNAL SOURCES: 17 | Flutter: 18 | :path: Flutter 19 | flutter_openim_sdk: 20 | :path: ".symlinks/plugins/flutter_openim_sdk/ios" 21 | 22 | SPEC CHECKSUMS: 23 | Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 24 | flutter_openim_sdk: 59aa0c08eb7499a1790168e10539e4dd915ced6e 25 | OpenIMSDKCore: bc9a6e5de2aabed76e4f69fe06a7c9df1d945afc 26 | 27 | PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796 28 | 29 | COCOAPODS: 1.16.2 30 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. 2 | # 3 | # You can adjust the behavior by modifying this file. 4 | # For more information, see: 5 | # https://github.com/actions/stale 6 | name: Mark stale issues and pull requests 7 | 8 | on: 9 | schedule: 10 | - cron: '33 21 * * *' 11 | 12 | jobs: 13 | stale: 14 | 15 | runs-on: ubuntu-latest 16 | permissions: 17 | issues: write 18 | pull-requests: write 19 | 20 | steps: 21 | - uses: actions/stale@v3 22 | with: 23 | repo-token: ${{ secrets.GITHUB_TOKEN }} 24 | stale-issue-message: 'Stale issue message' 25 | stale-pr-message: 'Stale pull request message' 26 | stale-issue-label: 'no-issue-activity' 27 | stale-pr-label: 'no-pr-activity' 28 | -------------------------------------------------------------------------------- /lib/src/utils.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | class Utils { 4 | static List toList(String value, T f(Map map)) => 5 | (formatJson(value) as List).map((e) => f(e)).toList(); 6 | 7 | static T toObj(String value, T f(Map map)) => f(formatJson(value)); 8 | 9 | static List toListMap(String value) => formatJson(value); 10 | 11 | static dynamic formatJson(String value) => jsonDecode(value); 12 | 13 | static String checkOperationID(String? obj) => obj ?? DateTime.now().millisecondsSinceEpoch.toString(); 14 | 15 | static Map cleanMap(Map map) { 16 | map.removeWhere((key, value) { 17 | if (value is Map) { 18 | cleanMap(value); 19 | } 20 | return value == null; 21 | }); 22 | return map; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/android/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | val flutterSdkPath = run { 3 | val properties = java.util.Properties() 4 | file("local.properties").inputStream().use { properties.load(it) } 5 | val flutterSdkPath = properties.getProperty("flutter.sdk") 6 | require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } 7 | flutterSdkPath 8 | } 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id("dev.flutter.flutter-plugin-loader") version "1.0.0" 21 | id("com.android.application") version "8.7.3" apply false 22 | id("org.jetbrains.kotlin.android") version "2.1.0" apply false 23 | } 24 | 25 | include(":app") 26 | -------------------------------------------------------------------------------- /.github/workflows/issue-translator.yml: -------------------------------------------------------------------------------- 1 | name: 'issue-translator' 2 | on: 3 | issue_comment: 4 | types: [created] 5 | issues: 6 | types: [opened] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: usthe/issues-translate-action@v2.7 13 | with: 14 | BOT_GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} 15 | IS_MODIFY_TITLE: true 16 | # not require, default false, . Decide whether to modify the issue title 17 | # if true, the robot account @Issues-translate-bot must have modification permissions, invite @Issues-translate-bot to your project or use your custom bot. 18 | CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿 19 | # not require. Customize the translation robot prefix message. 20 | -------------------------------------------------------------------------------- /flutter_openim_sdk.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .pub-cache/ 33 | .pub/ 34 | /build/ 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/manager/BaseManager.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.manager; 2 | 3 | import io.flutter.plugin.common.MethodCall; 4 | import io.openim.flutter_openim_sdk.util.JsonUtil; 5 | 6 | class BaseManager { 7 | 8 | static String jsonValue(MethodCall methodCall, String key) { 9 | return JsonUtil.toString(methodCall.argument(key)); 10 | } 11 | 12 | static String jsonValue(MethodCall methodCall) { 13 | return JsonUtil.toString(methodCall.arguments); 14 | } 15 | 16 | static T value(MethodCall methodCall, String key) { 17 | return methodCall.argument(key); 18 | } 19 | 20 | static Long int2long(MethodCall methodCall, String key) { 21 | Object i = value(methodCall, key); 22 | if (i instanceof Long) { 23 | return (Long) i; 24 | } 25 | return Long.valueOf((Integer) i); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnUploadLogsListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import android.util.ArrayMap; 4 | 5 | import java.util.Map; 6 | 7 | import io.flutter.plugin.common.MethodCall; 8 | import io.flutter.plugin.common.MethodChannel; 9 | import io.openim.flutter_openim_sdk.util.CommonUtil; 10 | import open_im_sdk_callback.UploadLogProgress; 11 | 12 | public class OnUploadLogsListener implements UploadLogProgress { 13 | final private MethodChannel.Result result; 14 | 15 | public OnUploadLogsListener(MethodChannel.Result result, MethodCall call) { 16 | this.result = result; 17 | } 18 | 19 | @Override 20 | public void onProgress(long current, long size) { 21 | final Map values = new ArrayMap<>(); 22 | values.put("current", current); 23 | values.put("size", size); 24 | CommonUtil.emitEvent("uploadLogsListener", "onProgress", values); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /README.zh-cn.md: -------------------------------------------------------------------------------- 1 | # flutter_openim_sdk 2 | image 3 | 4 | [![pub package](https://img.shields.io/pub/v/flutter_openim_sdk.svg)](https://pub.flutter-io.cn/packages/flutter_openim_sdk) 5 | [![Generic badge](https://img.shields.io/badge/platform-android%20|%20ios%20-blue.svg)](https://pub.dev/packages/flutter_openim_sdk) 6 | [![GitHub license](https://img.shields.io/github/license/OpenIMSDK/Open-IM-SDK-Flutter)](https://github.com/OpenIMSDK/Open-IM-SDK-Flutter/blob/main/LICENSE) 7 | 8 | A flutter im plugin for android and ios. 9 | 10 | #### [demo open source code](https://github.com/OpenIMSDK/Open-IM-Flutter-Demo.git) | [UI library source code](https://github.com/hrxiang/flutter_openim_widget.git) 11 | 12 | Scan the QR code below to experience the SDK call example Demo 13 | 14 | ![Android](https://www.pgyer.com/app/qrcode/OpenIM-Flutter) 15 | 16 | # [SDK Documents](https://doc.rentsoft.cn/sdks/quickstart/flutter) 17 | 18 | 19 | -------------------------------------------------------------------------------- /lib/src/enum/listener_type.dart: -------------------------------------------------------------------------------- 1 | /// Callback Types 2 | class ListenerType { 3 | static const simpleMsgListener = 'simpleMsgListener'; 4 | static const connectListener = 'connectListener'; 5 | static const userListener = 'userListener'; 6 | static const groupListener = 'groupListener'; 7 | static const advancedMsgListener = 'advancedMsgListener'; 8 | static const conversationListener = 'conversationListener'; 9 | static const friendListener = 'friendListener'; 10 | static const signalingListener = 'signalingListener'; 11 | static const msgSendProgressListener = "msgSendProgressListener"; 12 | static const workMomentsListener = "workMomentsListener"; 13 | static const organizationListener = "organizationListener"; 14 | static const customBusinessListener = "customBusinessListener"; 15 | static const messageKvInfoListener = "messageKvInfoListener"; 16 | static const listenerForService = "listenerForService"; 17 | static const uploadFileListener = "uploadFileListener"; 18 | static const uploadLogsListener = "uploadLogsListener"; 19 | } 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request (功能请求) 3 | about: Request a new feature that the package didn't include. (请求一个依赖并未包含的功能) 4 | title: "[Feature] Request a feature with something" 5 | labels: feature, await investigate 6 | 7 | --- 8 | 9 | **Version information** 10 | - Device: *e.g. iPhone X* 11 | - OS: *e.g. iOS 14.7.1* 12 | - Package Version: *e.g. v1.0.9* 13 | - Flutter Version: *e.g. v2.8.0* 14 | 15 | **Is your feature request related to a problem?** 16 | 18 | 19 | **Describe the solution you'd like** 20 | 22 | 23 | **Describe alternatives you've considered** 24 | 27 | 28 | **Additional context** 29 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnUserListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import io.openim.flutter_openim_sdk.util.CommonUtil; 4 | 5 | public class OnUserListener implements open_im_sdk_callback.OnUserListener { 6 | 7 | @Override 8 | public void onSelfInfoUpdated(String s) { 9 | CommonUtil.emitEvent("userListener", "onSelfInfoUpdated", s); 10 | } 11 | 12 | @Override 13 | public void onUserStatusChanged(String s) { 14 | CommonUtil.emitEvent("userListener", "onUserStatusChanged", s); 15 | } 16 | 17 | @Override 18 | public void onUserCommandAdd(String s) { 19 | CommonUtil.emitEvent("userListener", "onUserCommandAdd", s); 20 | } 21 | 22 | @Override 23 | public void onUserCommandDelete(String s) { 24 | CommonUtil.emitEvent("userListener", "onUserCommandDelete", s); 25 | } 26 | 27 | @Override 28 | public void onUserCommandUpdate(String s) { 29 | CommonUtil.emitEvent("userListener", "onUserCommandUpdate", s); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:flutter_openim_sdk_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnListenerForService.java: -------------------------------------------------------------------------------- 1 | //package io.openim.flutter_openim_sdk.listener; 2 | // 3 | //import io.openim.flutter_openim_sdk.util.CommonUtil; 4 | // 5 | //public class OnListenerForService implements open_im_sdk_callback.OnListenerForService { 6 | // @Override 7 | // public void onFriendApplicationAccepted(String s) { 8 | // CommonUtil.emitEvent("listenerForService", "onFriendApplicationAccepted", s); 9 | // } 10 | // 11 | // @Override 12 | // public void onFriendApplicationAdded(String s) { 13 | // CommonUtil.emitEvent("listenerForService", "onFriendApplicationAdded", s); 14 | // } 15 | // 16 | // @Override 17 | // public void onGroupApplicationAccepted(String s) { 18 | // CommonUtil.emitEvent("listenerForService", "onGroupApplicationAccepted", s); 19 | // } 20 | // 21 | // @Override 22 | // public void onGroupApplicationAdded(String s) { 23 | // CommonUtil.emitEvent("listenerForService", "onGroupApplicationAdded", s); 24 | // } 25 | // 26 | // @Override 27 | // public void onRecvNewMessage(String s) { 28 | // CommonUtil.emitEvent("listenerForService", "onRecvNewMessage", s); 29 | // } 30 | //} 31 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnConnListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | 4 | import io.openim.flutter_openim_sdk.util.CommonUtil; 5 | 6 | 7 | public class OnConnListener implements open_im_sdk_callback.OnConnListener { 8 | 9 | @Override 10 | public void onConnectFailed(int i, String s) { 11 | CommonUtil.emitEvent("connectListener", "onConnectFailed", i, s, null); 12 | } 13 | 14 | @Override 15 | public void onConnectSuccess() { 16 | CommonUtil.emitEvent("connectListener", "onConnectSuccess", null); 17 | } 18 | 19 | @Override 20 | public void onConnecting() { 21 | CommonUtil.emitEvent("connectListener", "onConnecting", null); 22 | } 23 | 24 | @Override 25 | public void onKickedOffline() { 26 | CommonUtil.emitEvent("connectListener", "onKickedOffline", null); 27 | } 28 | 29 | 30 | @Override 31 | public void onUserTokenExpired() { 32 | CommonUtil.emitEvent("connectListener", "onUserTokenExpired", null); 33 | } 34 | 35 | @Override 36 | public void onUserTokenInvalid(String s) { 37 | CommonUtil.emitEvent("connectListener", "onUserTokenInvalid", s); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/src/models/set_group_member_info.dart: -------------------------------------------------------------------------------- 1 | class SetGroupMemberInfo { 2 | SetGroupMemberInfo({ 3 | required this.groupID, 4 | required this.userID, 5 | this.roleLevel, 6 | this.nickname, 7 | this.faceURL, 8 | this.ex, 9 | }); 10 | 11 | final String groupID; 12 | final String userID; 13 | final int? roleLevel; 14 | final String? nickname; 15 | final String? faceURL; 16 | final String? ex; 17 | 18 | SetGroupMemberInfo.fromJson(Map json) 19 | : groupID = json['groupID'], 20 | userID = json['userID'], 21 | roleLevel = json['roleLevel'], 22 | nickname = json['nickname'], 23 | faceURL = json['faceURL'], 24 | ex = json['ex']; 25 | 26 | Map toJson() { 27 | final data = Map(); 28 | data['groupID'] = groupID; 29 | data['userID'] = userID; 30 | data['roleLevel'] = roleLevel; 31 | data['nickname'] = nickname; 32 | data['faceURL'] = faceURL; 33 | data['ex'] = ex; 34 | return data; 35 | } 36 | 37 | @override 38 | String toString() { 39 | return 'SetGroupMemberInfo{groupID: $groupID, userID: $userID, roleLevel: $roleLevel, nickname: $nickname, faceURL: $faceURL, ex: $ex}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ios/flutter_openim_sdk.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_openim_sdk.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_openim_sdk' 7 | s.version = '0.0.1' 8 | s.summary = 'A new Flutter project.' 9 | s.description = <<-DESC 10 | A new Flutter project. 11 | DESC 12 | s.homepage = 'http://example.com' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'Your Company' => 'email@example.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | s.platform = :ios, '11.0' 19 | 20 | s.dependency 'OpenIMSDKCore','3.8.3-hotfix.10' 21 | s.static_framework = true 22 | s.library = 'resolv' 23 | 24 | # s.vendored_frameworks = 'Framework/*.xcframework' 25 | # Flutter.framework does not contain a i386 slice. 26 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386 arm64' } 27 | s.swift_version = '5.0' 28 | 29 | s.resource_bundles = {'flutter_openim_sdk_privacy' => ['Resources/PrivacyInfo.xcprivacy']} 30 | end 31 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 3 | 4 | void main() { 5 | runApp(const MyApp()); 6 | } 7 | 8 | class MyApp extends StatefulWidget { 9 | const MyApp({super.key}); 10 | 11 | @override 12 | State createState() => _MyAppState(); 13 | } 14 | 15 | class _MyAppState extends State { 16 | @override 17 | void initState() { 18 | super.initState(); 19 | OpenIM.iMManager.initSDK( 20 | platformID: 2, 21 | apiAddr: 'https://www.openim.io/api', 22 | wsAddr: 'https://www.openim.io/', 23 | dataDir: '/', 24 | listener: OnConnectListener(), 25 | ); 26 | OpenIM.iMManager.messageManager.customBusinessListener = OnCustomBusinessListener( 27 | onRecvCustomBusinessMessage: (message) {}, 28 | ); 29 | } 30 | 31 | @override 32 | Widget build(BuildContext context) { 33 | return MaterialApp( 34 | home: Scaffold( 35 | appBar: AppBar( 36 | title: const Text('Plugin example app'), 37 | ), 38 | body: Column( 39 | children: [ 40 | TextButton(onPressed: () {}, child: const Text('login')), 41 | ], 42 | ), 43 | ), 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /android/src/test/java/com/example/flutter_openim_sdk/FlutterOpenimSdkPluginTest.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk; 2 | 3 | import static org.mockito.Mockito.mock; 4 | import static org.mockito.Mockito.verify; 5 | 6 | import io.flutter.plugin.common.MethodCall; 7 | import io.flutter.plugin.common.MethodChannel; 8 | import org.junit.Test; 9 | 10 | /** 11 | * This demonstrates a simple unit test of the Java portion of this plugin's 12 | * implementation. 13 | * 14 | * Once you have built the plugin's example app, you can run these tests from 15 | * the command 16 | * line by running `./gradlew testDebugUnitTest` in the `example/android/` 17 | * directory, or 18 | * you can run them directly from IDEs that support JUnit such as Android 19 | * Studio. 20 | */ 21 | 22 | public class FlutterOpenimSdkPluginTest { 23 | @Test 24 | public void onMethodCall_getPlatformVersion_returnsExpectedValue() { 25 | FlutterOpenimSdkPlugin plugin = new FlutterOpenimSdkPlugin(); 26 | 27 | final MethodCall call = new MethodCall("getPlatformVersion", null); 28 | MethodChannel.Result mockResult = mock(MethodChannel.Result.class); 29 | plugin.onMethodCall(call, mockResult); 30 | 31 | verify(mockResult).success("Android " + android.os.Build.VERSION.RELEASE); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/src/listener/listener_for_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 2 | 3 | /// Friend Relationship Listener 4 | class OnListenerForService { 5 | Function(FriendApplicationInfo i)? onFriendApplicationAdded; 6 | Function(FriendApplicationInfo i)? onFriendApplicationAccepted; 7 | Function(GroupApplicationInfo info)? onGroupApplicationAccepted; 8 | Function(GroupApplicationInfo info)? onGroupApplicationAdded; 9 | Function(Message msg)? onRecvNewMessage; 10 | 11 | OnListenerForService({ 12 | this.onFriendApplicationAdded, 13 | this.onFriendApplicationAccepted, 14 | this.onGroupApplicationAccepted, 15 | this.onGroupApplicationAdded, 16 | this.onRecvNewMessage, 17 | }); 18 | 19 | void friendApplicationAccepted(FriendApplicationInfo u) { 20 | onFriendApplicationAccepted?.call(u); 21 | } 22 | 23 | void friendApplicationAdded(FriendApplicationInfo u) { 24 | onFriendApplicationAdded?.call(u); 25 | } 26 | 27 | void groupApplicationAccepted(GroupApplicationInfo info) { 28 | onGroupApplicationAccepted?.call(info); 29 | } 30 | 31 | void groupApplicationAdded(GroupApplicationInfo info) { 32 | onGroupApplicationAdded?.call(info); 33 | } 34 | 35 | void recvNewMessage(Message msg) { 36 | onRecvNewMessage?.call(msg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group = "io.openim.flutter_openim_sdk" 2 | version = "1.0" 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | classpath("com.android.tools.build:gradle:8.7.3") 12 | } 13 | } 14 | 15 | rootProject.allprojects { 16 | repositories { 17 | google() 18 | mavenCentral() 19 | } 20 | } 21 | 22 | apply plugin: "com.android.library" 23 | 24 | android { 25 | namespace = "io.openim.flutter_openim_sdk" 26 | 27 | compileSdk = 35 28 | 29 | compileOptions { 30 | sourceCompatibility = JavaVersion.VERSION_11 31 | targetCompatibility = JavaVersion.VERSION_11 32 | } 33 | 34 | defaultConfig { 35 | minSdk = 21 36 | } 37 | 38 | dependencies { 39 | implementation 'io.openim:core-sdk:3.8.3-patch10@aar' 40 | testImplementation("junit:junit:4.13.2") 41 | testImplementation("org.mockito:mockito-core:5.0.0") 42 | } 43 | 44 | testOptions { 45 | unitTests.all { 46 | testLogging { 47 | events "passed", "skipped", "failed", "standardOut", "standardError" 48 | outputs.upToDateWhen {false} 49 | showStandardStreams = true 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report (BUG模板) 3 | about: Create a bug report helping us fix it. (创建一个 BUG 报告以帮助我们进行修复) 4 | title: "[BUG] Error with something" 5 | labels: await investigate, bug 6 | 7 | --- 8 | 9 | **Describe the bug** 10 | 12 | 13 | **How to reproduce** 14 | 19 | 20 | Steps to reproduce the behavior: 21 | 22 | 23 | 1. Go to '...' 24 | 2. Click on '....' 25 | 3. Scroll down to '....' 26 | 4. Error occurred. 27 | 28 | **Expected behavior** 29 | 31 | 32 | **Screenshots (If contains)** 33 | 35 | 36 | **Version information** 37 | - Device: *e.g. iPhone X* 38 | - OS: *e.g. iOS 14.7.1* 39 | - Package Version: *e.g. v1.0.9* 40 | - Flutter Version: *e.g. v2.8.0* 41 | 42 | **Additional context** 43 | 45 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnBaseListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | 4 | import io.flutter.Log; 5 | import io.flutter.plugin.common.MethodCall; 6 | import io.flutter.plugin.common.MethodChannel; 7 | import io.openim.flutter_openim_sdk.util.CommonUtil; 8 | import open_im_sdk_callback.Base; 9 | 10 | public class OnBaseListener implements Base { 11 | 12 | MethodChannel.Result result; 13 | MethodCall call; 14 | 15 | public OnBaseListener(MethodChannel.Result result, MethodCall call) { 16 | this.result = result; 17 | this.call = call; 18 | } 19 | 20 | @Override 21 | public void onError(int l, String s) { 22 | String threadName = Thread.currentThread().getName(); 23 | Log.i("F-OpenIMSDK(native call flutter)", "thread: " + threadName + " method: 【 " + call.method + " 】, onError: { code:" + l + ", message:" + s + "}"); 24 | CommonUtil.runMainThreadReturnError(result, l, s, null); 25 | } 26 | 27 | @Override 28 | public void onSuccess(String s) { 29 | String threadName = Thread.currentThread().getName(); 30 | Log.i("F-OpenIMSDK(native call flutter)", "thread: " + threadName + " method: 【 " + call.method + " 】, onSuccess: " + s); 31 | CommonUtil.runMainThreadReturn(result, s); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ios/Classes/Module/BaseServiceManager.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import OpenIMCore 3 | import UIKit 4 | 5 | public typealias ImHandler = (_ methodCall: FlutterMethodCall, _ result: @escaping FlutterResult) -> Void 6 | 7 | open class BaseServiceManager { 8 | public let channel: FlutterMethodChannel 9 | private var methodHandlers: [String: ImHandler] = [:] 10 | 11 | public init(channel: FlutterMethodChannel) { 12 | self.channel = channel 13 | self.registerHandlers() 14 | } 15 | 16 | public func handleMethod(call: FlutterMethodCall, result: @escaping FlutterResult) { 17 | let method: String = call.method 18 | guard let handler = methodHandlers[method] else { 19 | print("Handle MethodName Error: \(typeName(self))'s method: [\(method)] not found") 20 | return 21 | } 22 | handler(call, result) 23 | } 24 | 25 | public subscript(_ key: String) -> ImHandler? { 26 | get { 27 | methodHandlers[key] 28 | } 29 | set { 30 | methodHandlers[key] = newValue 31 | } 32 | } 33 | 34 | public func registerHandlers() { 35 | 36 | } 37 | 38 | public func callBack(_ result: @escaping FlutterResult, _ content: Any? = nil) { 39 | safeMainAsync { 40 | result(content) 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/src/listener/connect_listener.dart: -------------------------------------------------------------------------------- 1 | /// SDK Connection State Listener 2 | class OnConnectListener { 3 | Function(int? code, String? errorMsg)? onConnectFailed; 4 | Function()? onConnectSuccess; 5 | Function()? onConnecting; 6 | Function()? onKickedOffline; 7 | Function()? onUserTokenExpired; 8 | Function()? onUserTokenInvalid; 9 | 10 | OnConnectListener({ 11 | this.onConnectFailed, 12 | this.onConnectSuccess, 13 | this.onConnecting, 14 | this.onKickedOffline, 15 | this.onUserTokenExpired, 16 | this.onUserTokenInvalid, 17 | }); 18 | 19 | /// SDK failed to connect to the server 20 | void connectFailed(int? code, String? errorMsg) { 21 | onConnectFailed?.call(code, errorMsg); 22 | } 23 | 24 | /// SDK successfully connected to the server 25 | void connectSuccess() { 26 | onConnectSuccess?.call(); 27 | } 28 | 29 | /// SDK is currently connecting to the server 30 | void connecting() { 31 | onConnecting?.call(); 32 | } 33 | 34 | /// The account has been logged in from another location, and the current device has been kicked offline 35 | void kickedOffline() { 36 | onKickedOffline?.call(); 37 | } 38 | 39 | /// Login credentials have expired and require reauthentication 40 | void userTokenExpired() { 41 | onUserTokenExpired?.call(); 42 | } 43 | 44 | void userTokenInvalid() { 45 | onUserTokenInvalid?.call(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnMsgSendListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import android.util.ArrayMap; 4 | 5 | import java.util.Map; 6 | 7 | import io.flutter.plugin.common.MethodCall; 8 | import io.flutter.plugin.common.MethodChannel; 9 | import io.openim.flutter_openim_sdk.util.CommonUtil; 10 | import open_im_sdk_callback.SendMsgCallBack; 11 | 12 | public class OnMsgSendListener implements SendMsgCallBack { 13 | final private MethodChannel.Result result; 14 | private Object clientMsgID; 15 | 16 | public OnMsgSendListener(MethodChannel.Result result, MethodCall call) { 17 | this.result = result; 18 | Map args = call.argument("message"); 19 | if (null != args) { 20 | this.clientMsgID = args.get("clientMsgID"); 21 | } 22 | } 23 | 24 | @Override 25 | public void onError(int l, String s) { 26 | CommonUtil.runMainThreadReturnError(result, l, s, null); 27 | } 28 | 29 | @Override 30 | public void onProgress(long l) { 31 | if (null != clientMsgID) { 32 | final Map values = new ArrayMap<>(); 33 | values.put("clientMsgID", clientMsgID); 34 | values.put("progress", l); 35 | CommonUtil.emitEvent("msgSendProgressListener", "onProgress", values); 36 | } 37 | } 38 | 39 | @Override 40 | public void onSuccess(String s) { 41 | CommonUtil.runMainThreadReturn(result, s); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/src/models/init_config.dart: -------------------------------------------------------------------------------- 1 | class InitConfig { 2 | String systemType; 3 | int platformID; 4 | String apiAddr; 5 | String wsAddr; 6 | String dataDir; 7 | int logLevel; 8 | bool isLogStandardOutput; 9 | String? logFilePath; 10 | bool enabledCompression; 11 | 12 | InitConfig({ 13 | required this.platformID, 14 | required this.apiAddr, 15 | required this.wsAddr, 16 | required this.dataDir, 17 | this.logLevel = 6, 18 | this.isLogStandardOutput = true, 19 | this.logFilePath, 20 | this.enabledCompression = false, 21 | this.systemType = 'flutter', 22 | }); 23 | 24 | factory InitConfig.fromJson(Map json) { 25 | return InitConfig( 26 | platformID: json['platformID'], 27 | apiAddr: json['apiAddr'], 28 | wsAddr: json['wsAddr'], 29 | dataDir: json['dataDir'], 30 | logLevel: json['logLevel'], 31 | isLogStandardOutput: json['isLogStandardOutput'], 32 | logFilePath: json['logFilePath'], 33 | enabledCompression: json['isCompression'], 34 | systemType: json['systemType']); 35 | } 36 | 37 | Map toMap() { 38 | return { 39 | 'platformID': platformID, 40 | 'apiAddr': apiAddr, 41 | 'wsAddr': wsAddr, 42 | 'dataDir': dataDir, 43 | 'logLevel': logLevel, 44 | 'isLogStandardOutput': isLogStandardOutput, 45 | 'logFilePath': logFilePath, 46 | 'isCompression': enabledCompression, 47 | 'systemType': systemType, 48 | }; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /lib/src/listener/advanced_msg_listener.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 2 | 3 | /// Message Listener 4 | class OnAdvancedMsgListener { 5 | Function(Message msg)? onMsgDeleted; 6 | Function(RevokedInfo info)? onNewRecvMessageRevoked; 7 | Function(List list)? onRecvC2CReadReceipt; 8 | Function(Message msg)? onRecvNewMessage; 9 | Function(Message msg)? onRecvOfflineNewMessage; 10 | Function(Message msg)? onRecvOnlineOnlyMessage; 11 | 12 | /// Uniquely identifies 13 | String id; 14 | 15 | OnAdvancedMsgListener({ 16 | this.onMsgDeleted, 17 | this.onNewRecvMessageRevoked, 18 | this.onRecvC2CReadReceipt, 19 | this.onRecvNewMessage, 20 | this.onRecvOfflineNewMessage, 21 | this.onRecvOnlineOnlyMessage, 22 | }) : id = "id_${DateTime.now().microsecondsSinceEpoch}"; 23 | 24 | void msgDeleted(Message msg) { 25 | onMsgDeleted?.call(msg); 26 | } 27 | 28 | /// Message has been retracted 29 | void newRecvMessageRevoked(RevokedInfo info) { 30 | onNewRecvMessageRevoked?.call(info); 31 | } 32 | 33 | /// C2C Message Read Receipt 34 | void recvC2CReadReceipt(List list) { 35 | onRecvC2CReadReceipt?.call(list); 36 | } 37 | 38 | /// Received a new message 39 | void recvNewMessage(Message msg) { 40 | onRecvNewMessage?.call(msg); 41 | } 42 | 43 | void recvOfflineNewMessage(Message msg) { 44 | onRecvOfflineNewMessage?.call(msg); 45 | } 46 | 47 | void recvOnlineOnlyMessage(Message msg) { 48 | onRecvOnlineOnlyMessage?.call(msg); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /example/android/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id("dev.flutter.flutter-gradle-plugin") 6 | } 7 | 8 | android { 9 | namespace = "io.openim.flutter_openim_sdk_example" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_11 15 | targetCompatibility = JavaVersion.VERSION_11 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_11.toString() 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "io.openim.flutter_openim_sdk_example" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.getByName("debug") 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnFriendshipListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import io.openim.flutter_openim_sdk.util.CommonUtil; 4 | 5 | public class OnFriendshipListener implements open_im_sdk_callback.OnFriendshipListener { 6 | 7 | @Override 8 | public void onBlackAdded(String s) { 9 | CommonUtil.emitEvent("friendListener", "onBlackAdded", s); 10 | } 11 | 12 | @Override 13 | public void onBlackDeleted(String s) { 14 | CommonUtil.emitEvent("friendListener", "onBlackDeleted", s); 15 | } 16 | 17 | @Override 18 | public void onFriendAdded(String s) { 19 | CommonUtil.emitEvent("friendListener", "onFriendAdded", s); 20 | } 21 | 22 | @Override 23 | public void onFriendApplicationAccepted(String s) { 24 | CommonUtil.emitEvent("friendListener", "onFriendApplicationAccepted", s); 25 | } 26 | 27 | @Override 28 | public void onFriendApplicationAdded(String s) { 29 | CommonUtil.emitEvent("friendListener", "onFriendApplicationAdded", s); 30 | } 31 | 32 | @Override 33 | public void onFriendApplicationDeleted(String s) { 34 | CommonUtil.emitEvent("friendListener", "onFriendApplicationDeleted", s); 35 | } 36 | 37 | @Override 38 | public void onFriendApplicationRejected(String s) { 39 | CommonUtil.emitEvent("friendListener", "onFriendApplicationRejected", s); 40 | } 41 | 42 | @Override 43 | public void onFriendDeleted(String s) { 44 | CommonUtil.emitEvent("friendListener", "onFriendDeleted", s); 45 | } 46 | 47 | @Override 48 | public void onFriendInfoChanged(String s) { 49 | CommonUtil.emitEvent("friendListener", "onFriendInfoChanged", s); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnConversationListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import io.openim.flutter_openim_sdk.util.CommonUtil; 4 | 5 | 6 | public class OnConversationListener implements open_im_sdk_callback.OnConversationListener { 7 | 8 | @Override 9 | public void onConversationChanged(String s) { 10 | CommonUtil.emitEvent("conversationListener", "onConversationChanged", s); 11 | } 12 | 13 | @Override 14 | public void onConversationUserInputStatusChanged(String s) { 15 | CommonUtil.emitEvent("conversationListener", "onConversationUserInputStatusChanged", s); 16 | } 17 | 18 | @Override 19 | public void onNewConversation(String s) { 20 | CommonUtil.emitEvent("conversationListener", "onNewConversation", s); 21 | } 22 | 23 | @Override 24 | public void onSyncServerFailed(boolean reinstalled) { 25 | CommonUtil.emitEvent("conversationListener", "onSyncServerFailed", reinstalled); 26 | } 27 | 28 | @Override 29 | public void onSyncServerFinish(boolean reinstalled) { 30 | CommonUtil.emitEvent("conversationListener", "onSyncServerFinish", reinstalled); 31 | } 32 | 33 | @Override 34 | public void onSyncServerStart(boolean reinstalled) { 35 | CommonUtil.emitEvent("conversationListener", "onSyncServerStart", reinstalled); 36 | } 37 | 38 | @Override 39 | public void onSyncServerProgress(long progress) { 40 | CommonUtil.emitEvent("conversationListener", "onSyncServerProgress", progress); 41 | } 42 | 43 | @Override 44 | public void onTotalUnreadMessageCountChanged(int i) { 45 | CommonUtil.emitEvent("conversationListener", "onTotalUnreadMessageCountChanged", i); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/flutter_openim_sdk.dart: -------------------------------------------------------------------------------- 1 | library flutter_openim_sdk; 2 | 3 | export 'src/enum/conversation_type.dart'; 4 | export 'src/enum/group_at_type.dart'; 5 | export 'src/enum/group_role_level.dart'; 6 | export 'src/enum/group_type.dart'; 7 | export 'src/enum/group_verification.dart'; 8 | export 'src/enum/im_platform.dart'; 9 | export 'src/enum/listener_type.dart'; 10 | export 'src/enum/login_status.dart'; 11 | export 'src/enum/message_status.dart'; 12 | export 'src/enum/message_type.dart'; 13 | export 'src/enum/sdk_error_code.dart'; 14 | export 'src/listener/advanced_msg_listener.dart'; 15 | export 'src/listener/connect_listener.dart'; 16 | export 'src/listener/conversation_listener.dart'; 17 | export 'src/listener/custom_business_listener.dart'; 18 | export 'src/listener/friendship_listener.dart'; 19 | export 'src/listener/group_listener.dart'; 20 | export 'src/listener/listener_for_service.dart'; 21 | export 'src/listener/msg_send_progress_listener.dart'; 22 | export 'src/listener/upload_file_listener.dart'; 23 | export 'src/listener/user_listener.dart'; 24 | export 'src/manager/im_conversation_manager.dart'; 25 | export 'src/manager/im_friendship_manager.dart'; 26 | export 'src/manager/im_group_manager.dart'; 27 | export 'src/manager/im_manager.dart'; 28 | export 'src/manager/im_message_manager.dart'; 29 | export 'src/manager/im_user_manager.dart'; 30 | export 'src/models/conversation_info.dart'; 31 | export 'src/models/group_info.dart'; 32 | export 'src/models/init_config.dart'; 33 | export 'src/models/message.dart'; 34 | export 'src/models/notification_info.dart'; 35 | export 'src/models/search_info.dart'; 36 | export 'src/models/user_info.dart'; 37 | export 'src/models/input_status_changed_data.dart'; 38 | export 'src/models/set_group_member_info.dart'; 39 | export 'src/models/update_req.dart'; 40 | export 'src/openim.dart'; 41 | export 'src/utils.dart'; 42 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "b0850beeb25f6d5b10426284f506557f66181b36" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 17 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 18 | - platform: android 19 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 20 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 21 | - platform: ios 22 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 23 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 24 | - platform: linux 25 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 26 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 27 | - platform: macos 28 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 29 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 30 | - platform: web 31 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 32 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 33 | - platform: windows 34 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 35 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /lib/src/listener/conversation_listener.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 3 | 4 | /// Conversation Listener 5 | class OnConversationListener { 6 | Function(List list)? onConversationChanged; 7 | Function(List list)? onNewConversation; 8 | Function(int count)? onTotalUnreadMessageCountChanged; 9 | Function(bool? reinstalled)? onSyncServerStart; 10 | Function(int? progress)? onSyncServerProgress; 11 | Function(bool? reinstalled)? onSyncServerFinish; 12 | Function(bool? reinstalled)? onSyncServerFailed; 13 | ValueChanged? onInputStatusChanged; 14 | 15 | OnConversationListener({ 16 | this.onConversationChanged, 17 | this.onNewConversation, 18 | this.onTotalUnreadMessageCountChanged, 19 | this.onSyncServerStart, 20 | this.onSyncServerProgress, 21 | this.onSyncServerFinish, 22 | this.onSyncServerFailed, 23 | this.onInputStatusChanged, 24 | }); 25 | 26 | /// Conversations have changed 27 | void conversationChanged(List list) { 28 | onConversationChanged?.call(list); 29 | } 30 | 31 | /// New conversations have been created 32 | void newConversation(List list) { 33 | onNewConversation?.call(list); 34 | } 35 | 36 | /// Total unread message count has changed 37 | void totalUnreadMessageCountChanged(int count) { 38 | onTotalUnreadMessageCountChanged?.call(count); 39 | } 40 | 41 | void syncServerStart(bool? reinstalled) { 42 | onSyncServerStart?.call(reinstalled); 43 | } 44 | 45 | void syncServerProgress(int? progress) { 46 | onSyncServerProgress?.call(progress); 47 | } 48 | 49 | void syncServerFailed(bool? reinstalled) { 50 | onSyncServerFailed?.call(reinstalled); 51 | } 52 | 53 | void syncServerFinish(bool? reinstalled) { 54 | onSyncServerFinish?.call(reinstalled); 55 | } 56 | 57 | void conversationUserInputStatusChanged(InputStatusChangedData data) { 58 | onInputStatusChanged?.call(data); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnGroupListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import io.openim.flutter_openim_sdk.util.CommonUtil; 4 | 5 | public class OnGroupListener implements open_im_sdk_callback.OnGroupListener { 6 | 7 | @Override 8 | public void onGroupApplicationAccepted(String s) { 9 | CommonUtil.emitEvent("groupListener", "onGroupApplicationAccepted", s); 10 | } 11 | 12 | @Override 13 | public void onGroupApplicationAdded(String s) { 14 | CommonUtil.emitEvent("groupListener", "onGroupApplicationAdded", s); 15 | } 16 | 17 | @Override 18 | public void onGroupApplicationDeleted(String s) { 19 | CommonUtil.emitEvent("groupListener", "onGroupApplicationDeleted", s); 20 | } 21 | 22 | @Override 23 | public void onGroupApplicationRejected(String s) { 24 | CommonUtil.emitEvent("groupListener", "onGroupApplicationRejected", s); 25 | } 26 | 27 | @Override 28 | public void onGroupDismissed(String s) { 29 | CommonUtil.emitEvent("groupListener", "onGroupDismissed", s); 30 | } 31 | 32 | @Override 33 | public void onGroupInfoChanged(String s) { 34 | CommonUtil.emitEvent("groupListener", "onGroupInfoChanged", s); 35 | } 36 | 37 | @Override 38 | public void onGroupMemberAdded(String s) { 39 | CommonUtil.emitEvent("groupListener", "onGroupMemberAdded", s); 40 | } 41 | 42 | @Override 43 | public void onGroupMemberDeleted(String s) { 44 | CommonUtil.emitEvent("groupListener", "onGroupMemberDeleted", s); 45 | } 46 | 47 | @Override 48 | public void onGroupMemberInfoChanged(String s) { 49 | CommonUtil.emitEvent("groupListener", "onGroupMemberInfoChanged", s); 50 | } 51 | 52 | @Override 53 | public void onJoinedGroupAdded(String s) { 54 | CommonUtil.emitEvent("groupListener", "onJoinedGroupAdded", s); 55 | } 56 | 57 | @Override 58 | public void onJoinedGroupDeleted(String s) { 59 | CommonUtil.emitEvent("groupListener", "onJoinedGroupDeleted", s); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /ios/Classes/SwiftFlutterOpenimSdkPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin { 5 | let imManager: IMMananger 6 | let conversationManager: ConversationManager 7 | let friendshipManager: FriendshipManager 8 | let messageManager: MessageManager 9 | let groupManager: GroupManager 10 | let userManger: UserManager 11 | 12 | init(channel: FlutterMethodChannel) { 13 | self.imManager = IMMananger(channel: channel) 14 | self.conversationManager = ConversationManager(channel: channel) 15 | self.friendshipManager = FriendshipManager(channel: channel) 16 | self.messageManager = MessageManager(channel: channel) 17 | self.groupManager = GroupManager(channel: channel) 18 | self.userManger = UserManager(channel: channel) 19 | } 20 | 21 | public static func register(with registrar: FlutterPluginRegistrar) { 22 | let channel = FlutterMethodChannel(name: "flutter_openim_sdk", binaryMessenger: registrar.messenger()) 23 | let instance = SwiftFlutterOpenimSdkPlugin(channel: channel) 24 | registrar.addMethodCallDelegate(instance, channel: channel) 25 | } 26 | 27 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 28 | let managerName: String = call[string: "ManagerName"] 29 | switch managerName { 30 | case "imManager": 31 | imManager.handleMethod(call: call, result: result) 32 | case "conversationManager": 33 | conversationManager.handleMethod(call: call, result: result) 34 | case "messageManager": 35 | messageManager.handleMethod(call: call, result: result) 36 | case "friendshipManager": 37 | friendshipManager.handleMethod(call: call, result: result) 38 | case "groupManager": 39 | groupManager.handleMethod(call: call, result: result) 40 | case "userManager": 41 | userManger.handleMethod(call: call, result: result) 42 | default: 43 | print("Handle ManagerName Error: \(managerName) not found") 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /lib/src/listener/upload_file_listener.dart: -------------------------------------------------------------------------------- 1 | class OnUploadLogsListener { 2 | Function(int current, int size)? onUploadProgress; 3 | OnUploadLogsListener({this.onUploadProgress}); 4 | 5 | void onProgress(int current, int size) { 6 | onUploadProgress?.call(current, size); 7 | } 8 | } 9 | 10 | class OnUploadFileListener { 11 | OnUploadFileListener({ 12 | this.onComplete, 13 | this.onHashPartComplete, 14 | this.onHashPartProgress, 15 | this.onOpen, 16 | this.onPartSize, 17 | this.onUploadID, 18 | this.onUploadPartComplete, 19 | this.onUploadProgress, 20 | }); 21 | 22 | Function(String id, int size, String url, int type)? onComplete; 23 | Function(String id, String partHash, String fileHash)? onHashPartComplete; 24 | Function(String id, int index, int size, String partHash)? onHashPartProgress; 25 | Function(String id, int size)? onOpen; 26 | Function(String id, int partSize, int num)? onPartSize; 27 | Function(String id, int fileSize, int streamSize, int storageSize)? onUploadProgress; 28 | Function(String id, String uploadID)? onUploadID; 29 | Function(String id, int index, int partSize, String partHash)? onUploadPartComplete; 30 | 31 | void complete(String id, int size, String url, int type) { 32 | onComplete?.call(id, size, url, type); 33 | } 34 | 35 | void hashPartComplete(String id, String partHash, String fileHash) { 36 | onHashPartComplete?.call(id, partHash, fileHash); 37 | } 38 | 39 | void hashPartProgress(String id, int index, int size, String partHash) { 40 | onHashPartProgress?.call(id, index, size, partHash); 41 | } 42 | 43 | void open(String id, int size) { 44 | onOpen?.call(id, size); 45 | } 46 | 47 | void partSize(String id, int partSize, int num) { 48 | onPartSize?.call(id, partSize, num); 49 | } 50 | 51 | void uploadProgress(String id, int fileSize, int streamSize, int storageSize) { 52 | onUploadProgress?.call(id, fileSize, streamSize, storageSize); 53 | } 54 | 55 | void uploadID(String id, String uploadID) { 56 | onUploadID?.call(id, uploadID); 57 | } 58 | 59 | void uploadPartComplete(String id, int index, int partSize, String partHash) { 60 | onUploadPartComplete?.call(id, index, partSize, partHash); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /lib/src/listener/friendship_listener.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 2 | 3 | /// Friendship Listener 4 | class OnFriendshipListener { 5 | Function(BlacklistInfo info)? onBlackAdded; 6 | Function(BlacklistInfo info)? onBlackDeleted; 7 | Function(FriendInfo info)? onFriendAdded; 8 | Function(FriendApplicationInfo info)? onFriendApplicationAccepted; 9 | Function(FriendApplicationInfo info)? onFriendApplicationAdded; 10 | Function(FriendApplicationInfo info)? onFriendApplicationDeleted; 11 | Function(FriendApplicationInfo info)? onFriendApplicationRejected; 12 | Function(FriendInfo info)? onFriendDeleted; 13 | Function(FriendInfo info)? onFriendInfoChanged; 14 | 15 | OnFriendshipListener({ 16 | this.onBlackAdded, 17 | this.onBlackDeleted, 18 | this.onFriendAdded, 19 | this.onFriendApplicationAccepted, 20 | this.onFriendApplicationAdded, 21 | this.onFriendApplicationDeleted, 22 | this.onFriendApplicationRejected, 23 | this.onFriendDeleted, 24 | this.onFriendInfoChanged, 25 | }); 26 | 27 | /// Added to the blacklist 28 | void blackAdded(BlacklistInfo info) { 29 | onBlackAdded?.call(info); 30 | } 31 | 32 | /// Removed from the blacklist 33 | void blackDeleted(BlacklistInfo info) { 34 | onBlackDeleted?.call(info); 35 | } 36 | 37 | /// Friend added 38 | void friendAdded(FriendInfo info) { 39 | onFriendAdded?.call(info); 40 | } 41 | 42 | /// Friend application accepted 43 | void friendApplicationAccepted(FriendApplicationInfo info) { 44 | onFriendApplicationAccepted?.call(info); 45 | } 46 | 47 | /// New friend application added 48 | void friendApplicationAdded(FriendApplicationInfo info) { 49 | onFriendApplicationAdded?.call(info); 50 | } 51 | 52 | /// Friend application deleted 53 | void friendApplicationDeleted(FriendApplicationInfo info) { 54 | onFriendApplicationDeleted?.call(info); 55 | } 56 | 57 | /// Friend application rejected 58 | void friendApplicationRejected(FriendApplicationInfo info) { 59 | onFriendApplicationRejected?.call(info); 60 | } 61 | 62 | /// Friend deleted 63 | void friendDeleted(FriendInfo info) { 64 | onFriendDeleted?.call(info); 65 | } 66 | 67 | /// Friend information changed 68 | void friendInfoChanged(FriendInfo info) { 69 | onFriendInfoChanged?.call(info); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /.idea/libraries/Dart_SDK.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnAdvancedMsgListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import android.util.ArrayMap; 4 | 5 | import java.util.Map; 6 | 7 | import io.openim.flutter_openim_sdk.util.CommonUtil; 8 | 9 | public class OnAdvancedMsgListener implements open_im_sdk_callback.OnAdvancedMsgListener { 10 | private final String id; 11 | 12 | public OnAdvancedMsgListener(String listenerId) { 13 | this.id = listenerId; 14 | } 15 | 16 | @Override 17 | public void onMsgDeleted(String s) { 18 | final Map values = new ArrayMap<>(); 19 | values.put("id", id); 20 | values.put("message", s); 21 | CommonUtil.emitEvent("advancedMsgListener", "onMsgDeleted", values); 22 | } 23 | 24 | @Override 25 | public void onNewRecvMessageRevoked(String s) { 26 | final Map values = new ArrayMap<>(); 27 | values.put("id", id); 28 | values.put("messageRevoked", s); 29 | CommonUtil.emitEvent("advancedMsgListener", "onNewRecvMessageRevoked", values); 30 | } 31 | 32 | @Override 33 | public void onRecvC2CReadReceipt(String s) { 34 | final Map values = new ArrayMap<>(); 35 | values.put("id", id); 36 | values.put("msgReceiptList", s); 37 | CommonUtil.emitEvent("advancedMsgListener", "onRecvC2CReadReceipt", values); 38 | } 39 | 40 | @Override 41 | public void onRecvNewMessage(String s) { 42 | final Map values = new ArrayMap<>(); 43 | values.put("id", id); 44 | values.put("message", s); 45 | CommonUtil.emitEvent("advancedMsgListener", "onRecvNewMessage", values); 46 | } 47 | 48 | @Override 49 | public void onRecvOfflineNewMessage(String s) { 50 | final Map values = new ArrayMap<>(); 51 | values.put("id", id); 52 | values.put("message", s); 53 | CommonUtil.emitEvent("advancedMsgListener", "onRecvOfflineNewMessage", values); 54 | } 55 | 56 | @Override 57 | public void onRecvOnlineOnlyMessage(String s) { 58 | final Map values = new ArrayMap<>(); 59 | values.put("id", id); 60 | values.put("message", s); 61 | CommonUtil.emitEvent("advancedMsgListener", "onRecvOnlineOnlyMessage", values); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_openim_sdk 2 | description: An instant messaging plug-in that supports Android and IOS. And the server is also all open source. 3 | version: 3.8.3+hotfix.10.1 4 | homepage: https://www.openim.io 5 | repository: https://github.com/openimsdk/open-im-sdk-flutter 6 | 7 | environment: 8 | sdk: ">=3.0.0 <4.0.0" 9 | flutter: ">=1.20.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | dev_dependencies: 16 | flutter_test: 17 | sdk: flutter 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://dart.dev/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter. 23 | flutter: 24 | # This section identifies this Flutter project as a plugin project. 25 | # The 'pluginClass' and Android 'package' identifiers should not ordinarily 26 | # be modified. They are used by the tooling to maintain consistency when 27 | # adding or updating assets for this project. 28 | plugin: 29 | platforms: 30 | android: 31 | package: io.openim.flutter_openim_sdk 32 | pluginClass: FlutterOpenimSdkPlugin 33 | ios: 34 | pluginClass: FlutterOpenimSdkPlugin 35 | 36 | # To add assets to your plugin package, add an assets section, like this: 37 | # assets: 38 | # - images/a_dot_burr.jpeg 39 | # - images/a_dot_ham.jpeg 40 | # 41 | # For details regarding assets in packages, see 42 | # https://flutter.dev/assets-and-images/#from-packages 43 | # 44 | # An image asset can refer to one or more resolution-specific "variants", see 45 | # https://flutter.dev/assets-and-images/#resolution-aware. 46 | 47 | # To add custom fonts to your plugin package, add a fonts section here, 48 | # in this "flutter" section. Each entry in this list should have a 49 | # "family" key with the font family name, and a "fonts" key with a 50 | # list giving the asset and other descriptors for the font. For 51 | # example: 52 | # fonts: 53 | # - family: Schyler 54 | # fonts: 55 | # - asset: fonts/Schyler-Regular.ttf 56 | # - asset: fonts/Schyler-Italic.ttf 57 | # style: italic 58 | # - family: Trajan Pro 59 | # fonts: 60 | # - asset: fonts/TrajanPro.ttf 61 | # - asset: fonts/TrajanPro_Bold.ttf 62 | # weight: 700 63 | # 64 | # For details regarding fonts in packages, see 65 | # https://flutter.dev/custom-fonts/#from-packages 66 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/util/CommonUtil.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.util; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | 6 | import androidx.collection.ArrayMap; 7 | 8 | import java.util.Map; 9 | 10 | import io.flutter.Log; 11 | import io.flutter.plugin.common.MethodChannel; 12 | import io.openim.flutter_openim_sdk.FlutterOpenimSdkPlugin; 13 | 14 | 15 | public class CommonUtil { 16 | private final static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper()); 17 | 18 | public static void runMainThreadReturn(final MethodChannel.Result result, final Object param) { 19 | MAIN_HANDLER.post(() -> result.success(param)); 20 | } 21 | 22 | public static void runMainThread(Runnable runnable) { 23 | MAIN_HANDLER.post(runnable); 24 | } 25 | 26 | 27 | public static void runMainThreadReturnError(final MethodChannel.Result result, final String errorCode, final String errorMessage, final Object errorDetails) { 28 | MAIN_HANDLER.post(() -> result.error(errorCode, errorMessage, errorDetails)); 29 | } 30 | 31 | public static void runMainThreadReturnError(final MethodChannel.Result result, final long errorCode, final String errorMessage, final Object errorDetails) { 32 | runMainThreadReturnError(result, String.valueOf(errorCode), errorMessage, errorDetails); 33 | } 34 | 35 | public synchronized static void emitEvent(String method, String type, Object errCode, String errMsg, T data) { 36 | String threadName = Thread.currentThread().getName(); 37 | runMainThread(() -> { 38 | Map res = new ArrayMap<>(); 39 | if (null != type) { 40 | res.put("type", type); 41 | } 42 | if (null != data) { 43 | res.put("data", data); 44 | } 45 | if (null != errCode) { 46 | res.put("errCode", errCode); 47 | } 48 | if (null != errMsg) { 49 | res.put("errMsg", errMsg); 50 | } 51 | Log.i("F-OpenIMSDK(native call flutter)", "thread: " + threadName + " { method:" + method + ", type:" + type + " }"); 52 | FlutterOpenimSdkPlugin.channel.invokeMethod(method, res); 53 | }); 54 | } 55 | 56 | public static void emitEvent(String method, String type, T data) { 57 | emitEvent(method, type, null, null, data); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/connectivity/VisibilityListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.connectivity; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.os.Bundle; 6 | 7 | import androidx.annotation.NonNull; 8 | import androidx.annotation.Nullable; 9 | 10 | import io.flutter.Log; 11 | import io.openim.flutter_openim_sdk.FlutterOpenimSdkPlugin; 12 | import open_im_sdk.Open_im_sdk; 13 | 14 | public class VisibilityListener implements Application.ActivityLifecycleCallbacks, open_im_sdk_callback.Base { 15 | public void register(Activity activity) { 16 | if (null != activity) { 17 | activity.getApplication().registerActivityLifecycleCallbacks(this); 18 | } 19 | } 20 | 21 | public void unregisterReceiver(Activity activity) { 22 | if (null != activity) { 23 | activity.getApplication().unregisterActivityLifecycleCallbacks(this); 24 | } 25 | } 26 | 27 | 28 | @Override 29 | public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) { 30 | Log.i("VisibilityListener", "onActivityCreated"); 31 | } 32 | 33 | @Override 34 | public void onActivityStarted(@NonNull Activity activity) { 35 | Log.i("VisibilityListener", "onActivityStarted"); 36 | } 37 | 38 | @Override 39 | public void onActivityResumed(@NonNull Activity activity) { 40 | Log.i("VisibilityListener", "onActivityResumed"); 41 | if (FlutterOpenimSdkPlugin.isInitialized) { 42 | Open_im_sdk.setAppBackgroundStatus(this, String.valueOf(System.currentTimeMillis()), false); 43 | } 44 | } 45 | 46 | @Override 47 | public void onActivityPaused(@NonNull Activity activity) { 48 | Log.i("VisibilityListener", "onActivityPaused"); 49 | if (FlutterOpenimSdkPlugin.isInitialized) { 50 | Open_im_sdk.setAppBackgroundStatus(this, String.valueOf(System.currentTimeMillis()), true); 51 | } 52 | } 53 | 54 | @Override 55 | public void onActivityStopped(@NonNull Activity activity) { 56 | Log.i("VisibilityListener", "onActivityStopped"); 57 | } 58 | 59 | @Override 60 | public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) { 61 | Log.i("VisibilityListener", "onActivitySaveInstanceState"); 62 | } 63 | 64 | @Override 65 | public void onActivityDestroyed(@NonNull Activity activity) { 66 | Log.i("VisibilityListener", "onActivityDestroyed"); 67 | } 68 | 69 | @Override 70 | public void onError(int i, String s) { 71 | 72 | } 73 | 74 | @Override 75 | public void onSuccess(String s) { 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/manager/UserManager.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.manager; 2 | 3 | import io.flutter.plugin.common.MethodCall; 4 | import io.flutter.plugin.common.MethodChannel; 5 | import io.openim.flutter_openim_sdk.listener.OnBaseListener; 6 | import io.openim.flutter_openim_sdk.listener.OnUserListener; 7 | import open_im_sdk.Open_im_sdk; 8 | 9 | public class UserManager extends BaseManager { 10 | 11 | public void setUserListener(MethodCall methodCall, MethodChannel.Result result) { 12 | Open_im_sdk.setUserListener(new OnUserListener()); 13 | 14 | result.success(null); 15 | } 16 | 17 | public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) { 18 | Open_im_sdk.getUsersInfo( 19 | new OnBaseListener(result, methodCall), 20 | value(methodCall, "operationID"), 21 | jsonValue(methodCall, "userIDList")); 22 | } 23 | 24 | public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) { 25 | Open_im_sdk.setSelfInfo( 26 | new OnBaseListener(result, methodCall), 27 | value(methodCall, "operationID"), 28 | jsonValue(methodCall)); 29 | } 30 | 31 | public void getSelfUserInfo(MethodCall methodCall, MethodChannel.Result result) { 32 | Open_im_sdk.getSelfUserInfo( 33 | new OnBaseListener(result, methodCall), 34 | value(methodCall, "operationID") 35 | ); 36 | } 37 | public void subscribeUsersStatus(MethodCall methodCall, MethodChannel.Result result) { 38 | Open_im_sdk.subscribeUsersStatus( 39 | new OnBaseListener(result, methodCall), 40 | value(methodCall, "operationID"), 41 | jsonValue(methodCall, "userIDs")); 42 | } 43 | 44 | public void unsubscribeUsersStatus(MethodCall methodCall, MethodChannel.Result result) { 45 | Open_im_sdk.unsubscribeUsersStatus( 46 | new OnBaseListener(result, methodCall), 47 | value(methodCall, "operationID"), 48 | jsonValue(methodCall, "userIDs")); 49 | } 50 | 51 | public void getSubscribeUsersStatus(MethodCall methodCall, MethodChannel.Result result) { 52 | Open_im_sdk.getSubscribeUsersStatus( 53 | new OnBaseListener(result, methodCall), 54 | value(methodCall, "operationID") 55 | ); 56 | } 57 | 58 | public void getUserStatus(MethodCall methodCall, MethodChannel.Result result) { 59 | Open_im_sdk.getUserStatus( 60 | new OnBaseListener(result, methodCall), 61 | value(methodCall, "operationID"), 62 | jsonValue(methodCall, "userIDs")); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/src/models/update_req.dart: -------------------------------------------------------------------------------- 1 | class UpdateFriendsReq { 2 | final String? ownerUserID; 3 | final List? friendUserIDs; 4 | final bool? isPinned; 5 | final String? remark; 6 | final String? ex; 7 | 8 | UpdateFriendsReq({ 9 | this.ownerUserID, 10 | this.friendUserIDs, 11 | this.isPinned, 12 | this.remark, 13 | this.ex, 14 | }); 15 | 16 | UpdateFriendsReq.fromJson(Map json) 17 | : ownerUserID = json['ownerUserID'], 18 | friendUserIDs = json['friendUserIDs'], 19 | isPinned = json['isPinned'], 20 | remark = json['remark'], 21 | ex = json['ex']; 22 | 23 | Map toJson() { 24 | final data = {}; 25 | data['ownerUserID'] = ownerUserID; 26 | data['friendUserIDs'] = friendUserIDs; 27 | data['isPinned'] = isPinned; 28 | data['remark'] = remark; 29 | data['ex'] = ex; 30 | return data; 31 | } 32 | 33 | @override 34 | String toString() { 35 | return 'UpdateFriendsReq{ownerUserID: $ownerUserID, friendUserIDs: $friendUserIDs, isPinned: $isPinned, remark: $remark, ex: $ex}'; 36 | } 37 | } 38 | 39 | class ConversationReq { 40 | final String? userID; 41 | final String? groupID; 42 | final int? recvMsgOpt; 43 | final bool? isPinned; 44 | final bool? isPrivateChat; 45 | final String? ex; 46 | final int? burnDuration; 47 | final bool? isMsgDestruct; 48 | final int? msgDestructTime; 49 | final int? groupAtType; 50 | 51 | ConversationReq({ 52 | this.userID, 53 | this.groupID, 54 | this.recvMsgOpt, 55 | this.isPinned, 56 | this.isPrivateChat, 57 | this.ex, 58 | this.burnDuration, 59 | this.isMsgDestruct, 60 | this.msgDestructTime, 61 | this.groupAtType, 62 | }); 63 | 64 | ConversationReq.fromJson(Map json) 65 | : userID = json['userID'], 66 | groupID = json['groupID'], 67 | recvMsgOpt = json['recvMsgOpt'], 68 | isPinned = json['isPinned'], 69 | isPrivateChat = json['isPrivateChat'], 70 | ex = json['ex'], 71 | burnDuration = json['burnDuration'], 72 | isMsgDestruct = json['isMsgDestruct'], 73 | msgDestructTime = json['msgDestructTime'], 74 | groupAtType = json['groupAtType']; 75 | 76 | Map toJson() { 77 | final data = {}; 78 | data['userID'] = userID; 79 | data['groupID'] = groupID; 80 | data['recvMsgOpt'] = recvMsgOpt; 81 | data['isPinned'] = isPinned; 82 | data['isPrivateChat'] = isPrivateChat; 83 | data['ex'] = ex; 84 | data['burnDuration'] = burnDuration; 85 | data['isMsgDestruct'] = isMsgDestruct; 86 | data['msgDestructTime'] = msgDestructTime; 87 | data['groupAtType'] = groupAtType; 88 | 89 | return data; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /lib/src/listener/group_listener.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 2 | 3 | /// Group Listener 4 | class OnGroupListener { 5 | Function(GroupApplicationInfo info)? onGroupApplicationAccepted; 6 | Function(GroupApplicationInfo info)? onGroupApplicationAdded; 7 | Function(GroupApplicationInfo info)? onGroupApplicationDeleted; 8 | Function(GroupApplicationInfo info)? onGroupApplicationRejected; 9 | Function(GroupInfo info)? onGroupDismissed; 10 | Function(GroupInfo info)? onGroupInfoChanged; 11 | Function(GroupMembersInfo info)? onGroupMemberAdded; 12 | Function(GroupMembersInfo info)? onGroupMemberDeleted; 13 | Function(GroupMembersInfo info)? onGroupMemberInfoChanged; 14 | Function(GroupInfo info)? onJoinedGroupAdded; 15 | Function(GroupInfo info)? onJoinedGroupDeleted; 16 | 17 | OnGroupListener({ 18 | this.onGroupApplicationAccepted, 19 | this.onGroupApplicationAdded, 20 | this.onGroupApplicationDeleted, 21 | this.onGroupApplicationRejected, 22 | this.onGroupDismissed, 23 | this.onGroupInfoChanged, 24 | this.onGroupMemberAdded, 25 | this.onGroupMemberDeleted, 26 | this.onGroupMemberInfoChanged, 27 | this.onJoinedGroupAdded, 28 | this.onJoinedGroupDeleted, 29 | }); 30 | 31 | /// Group application accepted 32 | void groupApplicationAccepted(GroupApplicationInfo info) { 33 | onGroupApplicationAccepted?.call(info); 34 | } 35 | 36 | /// Group application added 37 | void groupApplicationAdded(GroupApplicationInfo info) { 38 | onGroupApplicationAdded?.call(info); 39 | } 40 | 41 | /// Group application deleted 42 | void groupApplicationDeleted(GroupApplicationInfo info) { 43 | onGroupApplicationDeleted?.call(info); 44 | } 45 | 46 | /// Group application rejected 47 | void groupApplicationRejected(GroupApplicationInfo info) { 48 | onGroupApplicationRejected?.call(info); 49 | } 50 | 51 | void groupDismissed(GroupInfo info) { 52 | onGroupDismissed?.call(info); 53 | } 54 | 55 | /// Group information changed 56 | void groupInfoChanged(GroupInfo info) { 57 | onGroupInfoChanged?.call(info); 58 | } 59 | 60 | /// Group member added 61 | void groupMemberAdded(GroupMembersInfo info) { 62 | onGroupMemberAdded?.call(info); 63 | } 64 | 65 | /// Group member deleted 66 | void groupMemberDeleted(GroupMembersInfo info) { 67 | onGroupMemberDeleted?.call(info); 68 | } 69 | 70 | /// Group member information changed 71 | void groupMemberInfoChanged(GroupMembersInfo info) { 72 | onGroupMemberInfoChanged?.call(info); 73 | } 74 | 75 | /// Joined group added 76 | void joinedGroupAdded(GroupInfo info) { 77 | onJoinedGroupAdded?.call(info); 78 | } 79 | 80 | /// Joined group deleted 81 | void joinedGroupDeleted(GroupInfo info) { 82 | onJoinedGroupDeleted?.call(info); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Classes/Util/FlutterMethodCall+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FlutterMethodCall+Extension.swift 3 | // flutter_openim_sdk 4 | // 5 | // Created by willem on 2021/10/9. 6 | // 7 | 8 | import Foundation 9 | import Flutter 10 | 11 | public protocol Stringable { 12 | var rawValue: String { get } 13 | } 14 | 15 | extension String: Stringable { 16 | public var rawValue: String { self } 17 | } 18 | 19 | public extension FlutterMethodCall { 20 | subscript(_ key: Stringable) -> Any? { 21 | guard let params = self.arguments as? [String: Any] else { 22 | return nil 23 | } 24 | return params[key.rawValue] 25 | } 26 | 27 | subscript(string key: Stringable) -> String { 28 | return self[key] as? String ?? "" 29 | } 30 | 31 | subscript(jsonString key: Stringable) -> String { 32 | guard let params = self.arguments as? [String: Any] else { 33 | return "" 34 | } 35 | let arg = params[key.rawValue] as AnyObject 36 | return JsonUtil.toString(object: arg) 37 | } 38 | 39 | subscript(int32 key: Stringable) -> Int32 { 40 | guard let value = self[key] else { 41 | return 0 42 | } 43 | if let value = value as? Int32 { 44 | return value 45 | } else if let value = value as? String { 46 | return Int32(value) ?? 0 47 | } 48 | return 0 49 | } 50 | 51 | subscript(int64 key: Stringable) -> Int64 { 52 | guard let value = self[key] else { 53 | return 0 54 | } 55 | if let value = value as? Int64 { 56 | return value 57 | } else if let value = value as? String { 58 | return Int64(value) ?? 0 59 | } 60 | return 0 61 | } 62 | 63 | subscript(int key: Stringable) -> Int { 64 | guard let value = self[key] else { 65 | return 0 66 | } 67 | if let value = value as? Int { 68 | return value 69 | } else if let value = value as? String { 70 | return Int(value) ?? 0 71 | } 72 | return 0 73 | } 74 | 75 | subscript(double key: Stringable) -> Double { 76 | guard let value = self[key] else { 77 | return 0 78 | } 79 | if let value = value as? Double { 80 | return value 81 | } else if let value = value as? String { 82 | return Double(value) ?? 0.0 83 | } 84 | return 0 85 | } 86 | 87 | subscript(bool key: Stringable, default default: Bool = false) -> Bool { 88 | guard let value = self[key] else { 89 | return `default` 90 | } 91 | if let value = value as? Bool { 92 | return value 93 | } else if let value = value as? Int { 94 | return value != 0 95 | } else if let value = value as? NSString { 96 | return value.boolValue 97 | } 98 | return `default` 99 | } 100 | 101 | subscript(dict key: Stringable) -> [AnyHashable: Any] { 102 | return self[key] as? [AnyHashable: Any] ?? [:] 103 | } 104 | 105 | func toJsonString() -> String { 106 | let params = self.arguments as AnyObject 107 | return JsonUtil.toString(object: params) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/connectivity/Connectivity.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.connectivity; 2 | 3 | import android.net.ConnectivityManager; 4 | import android.net.Network; 5 | import android.net.NetworkCapabilities; 6 | import android.os.Build; 7 | 8 | public class Connectivity { 9 | static final String CONNECTIVITY_NONE = "none"; 10 | static final String CONNECTIVITY_WIFI = "wifi"; 11 | static final String CONNECTIVITY_MOBILE = "mobile"; 12 | static final String CONNECTIVITY_ETHERNET = "ethernet"; 13 | static final String CONNECTIVITY_BLUETOOTH = "bluetooth"; 14 | static final String CONNECTIVITY_VPN = "vpn"; 15 | private final ConnectivityManager connectivityManager; 16 | 17 | public Connectivity(ConnectivityManager connectivityManager) { 18 | this.connectivityManager = connectivityManager; 19 | } 20 | 21 | String getNetworkType() { 22 | if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 23 | Network network = connectivityManager.getActiveNetwork(); 24 | NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network); 25 | if (capabilities == null) { 26 | return CONNECTIVITY_NONE; 27 | } 28 | if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) { 29 | return CONNECTIVITY_WIFI; 30 | } 31 | if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) { 32 | return CONNECTIVITY_ETHERNET; 33 | } 34 | if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) { 35 | return CONNECTIVITY_VPN; 36 | } 37 | if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) { 38 | return CONNECTIVITY_MOBILE; 39 | } 40 | if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)) { 41 | return CONNECTIVITY_BLUETOOTH; 42 | } 43 | } 44 | 45 | return getNetworkTypeLegacy(); 46 | } 47 | 48 | @SuppressWarnings("deprecation") 49 | private String getNetworkTypeLegacy() { 50 | // handle type for Android versions less than Android 6 51 | android.net.NetworkInfo info = connectivityManager.getActiveNetworkInfo(); 52 | if (info == null || !info.isConnected()) { 53 | return CONNECTIVITY_NONE; 54 | } 55 | int type = info.getType(); 56 | switch (type) { 57 | case ConnectivityManager.TYPE_BLUETOOTH: 58 | return CONNECTIVITY_BLUETOOTH; 59 | case ConnectivityManager.TYPE_ETHERNET: 60 | return CONNECTIVITY_ETHERNET; 61 | case ConnectivityManager.TYPE_WIFI: 62 | case ConnectivityManager.TYPE_WIMAX: 63 | return CONNECTIVITY_WIFI; 64 | case ConnectivityManager.TYPE_VPN: 65 | return CONNECTIVITY_VPN; 66 | case ConnectivityManager.TYPE_MOBILE: 67 | case ConnectivityManager.TYPE_MOBILE_DUN: 68 | case ConnectivityManager.TYPE_MOBILE_HIPRI: 69 | return CONNECTIVITY_MOBILE; 70 | default: 71 | return CONNECTIVITY_NONE; 72 | } 73 | } 74 | 75 | public ConnectivityManager getConnectivityManager() { 76 | return connectivityManager; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /ios/Classes/Module/UserManager.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import OpenIMCore 3 | 4 | public class UserManager: BaseServiceManager { 5 | 6 | public override func registerHandlers() { 7 | super.registerHandlers() 8 | self["setUserListener"] = setUserListener 9 | self["getUsersInfo"] = getUsersInfo 10 | self["setSelfInfo"] = setSelfInfo 11 | self["getSelfUserInfo"] = getSelfUserInfo 12 | self["subscribeUsersStatus"] = subscribeUsersStatus 13 | self["unsubscribeUsersStatus"] = unsubscribeUsersStatus 14 | self["getSubscribeUsersStatus"] = getSubscribeUsersStatus 15 | self["getUserStatus"] = getUserStatus 16 | } 17 | 18 | func setUserListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ 19 | Open_im_sdkSetUserListener(UserListener(channel: channel)) 20 | callBack(result) 21 | } 22 | 23 | func getUsersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { 24 | Open_im_sdkGetUsersInfo(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "userIDList"]) 25 | } 26 | 27 | func setSelfInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { 28 | Open_im_sdkSetSelfInfo(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString()) 29 | } 30 | 31 | func getSelfUserInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { 32 | Open_im_sdkGetSelfUserInfo(BaseCallback(result: result), methodCall[string: "operationID"]) 33 | } 34 | 35 | func subscribeUsersStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ 36 | Open_im_sdkSubscribeUsersStatus(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "userIDs"]) 37 | } 38 | 39 | func unsubscribeUsersStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ 40 | Open_im_sdkUnsubscribeUsersStatus(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "userIDs"]) 41 | } 42 | 43 | func getSubscribeUsersStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ 44 | Open_im_sdkGetSubscribeUsersStatus(BaseCallback(result: result), methodCall[string: "operationID"]) 45 | } 46 | 47 | func getUserStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ 48 | Open_im_sdkGetUserStatus(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "userIDs"]) 49 | } 50 | } 51 | 52 | public class UserListener: NSObject, Open_im_sdk_callbackOnUserListenerProtocol { 53 | public func onUserCommandAdd(_ userCommand: String?) { 54 | CommonUtil.emitEvent(channel: self.channel, method: "userListener", type: "onUserCommandAdd", errCode: nil, errMsg: nil, data: userCommand) 55 | } 56 | 57 | public func onUserCommandDelete(_ userCommand: String?) { 58 | CommonUtil.emitEvent(channel: self.channel, method: "userListener", type: "onUserCommandDelete", errCode: nil, errMsg: nil, data: userCommand) 59 | } 60 | 61 | public func onUserCommandUpdate(_ userCommand: String?) { 62 | CommonUtil.emitEvent(channel: self.channel, method: "userListener", type: "onUserCommandUpdate", errCode: nil, errMsg: nil, data: userCommand) 63 | } 64 | 65 | 66 | private let channel:FlutterMethodChannel 67 | 68 | init(channel:FlutterMethodChannel) { 69 | self.channel = channel 70 | } 71 | 72 | public func onSelfInfoUpdated(_ userInfo: String?) { 73 | CommonUtil.emitEvent(channel: self.channel, method: "userListener", type: "onSelfInfoUpdated", errCode: nil, errMsg: nil, data: userInfo) 74 | } 75 | 76 | public func onUserStatusChanged(_ statusInfo: String?) { 77 | CommonUtil.emitEvent(channel: self.channel, method: "userListener", type: "onUserStatusChanged", errCode: nil, errMsg: nil, data: statusInfo) 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/connectivity/ConnectivityListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.connectivity; 2 | 3 | 4 | import android.content.BroadcastReceiver; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.IntentFilter; 8 | import android.net.ConnectivityManager; 9 | import android.net.Network; 10 | import android.os.Build; 11 | 12 | import io.flutter.Log; 13 | import io.openim.flutter_openim_sdk.FlutterOpenimSdkPlugin; 14 | import open_im_sdk.Open_im_sdk; 15 | 16 | 17 | public class ConnectivityListener implements open_im_sdk_callback.Base { 18 | public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE"; 19 | private Context context; 20 | private ConnectivityManager connectivityManager; 21 | private Connectivity connectivity; 22 | private ConnectivityBroadcastReceiver receiver; 23 | private ConnectivityManager.NetworkCallback networkCallback; 24 | 25 | public ConnectivityListener(Context context) { 26 | this.context = context; 27 | this.connectivityManager = 28 | (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 29 | this.connectivity = new Connectivity(connectivityManager); 30 | this.receiver = new ConnectivityBroadcastReceiver(this); 31 | } 32 | 33 | private void onChangedNetworkStatus() { 34 | String status = connectivity.getNetworkType(); 35 | if (Connectivity.CONNECTIVITY_MOBILE.equals(status) || Connectivity.CONNECTIVITY_WIFI.equals(status)) { 36 | Log.i("ConnectivityListener", "networkStatusChanged: " + status); 37 | if (FlutterOpenimSdkPlugin.isInitialized) { 38 | Open_im_sdk.networkStatusChanged(this, String.valueOf(System.currentTimeMillis())); 39 | } 40 | } 41 | } 42 | 43 | public void register() { 44 | if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 45 | networkCallback = new ConnectivityManager.NetworkCallback() { 46 | @Override 47 | public void onAvailable(Network network) { 48 | onChangedNetworkStatus(); 49 | } 50 | 51 | @Override 52 | public void onLost(Network network) { 53 | } 54 | }; 55 | connectivity.getConnectivityManager().registerDefaultNetworkCallback(networkCallback); 56 | } else { 57 | context.registerReceiver(receiver, new IntentFilter(CONNECTIVITY_ACTION)); 58 | } 59 | } 60 | 61 | public void unregisterReceiver() { 62 | if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 63 | if (networkCallback != null) { 64 | connectivity.getConnectivityManager().unregisterNetworkCallback(networkCallback); 65 | networkCallback = null; 66 | } 67 | } else { 68 | try { 69 | context.unregisterReceiver(receiver); 70 | receiver = null; 71 | } catch (Exception e) { 72 | //listen never called, ignore the error 73 | } 74 | } 75 | } 76 | 77 | @Override 78 | public void onError(int i, String s) { 79 | 80 | } 81 | 82 | @Override 83 | public void onSuccess(String s) { 84 | 85 | } 86 | 87 | public static class ConnectivityBroadcastReceiver extends BroadcastReceiver { 88 | ConnectivityListener listener; 89 | 90 | public ConnectivityBroadcastReceiver(ConnectivityListener listener) { 91 | this.listener = listener; 92 | } 93 | 94 | @Override 95 | public void onReceive(Context context, Intent intent) { 96 | if (null != listener && CONNECTIVITY_ACTION.equals(intent.getAction())) { 97 | listener.onChangedNetworkStatus(); 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /lib/src/models/search_info.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 2 | 3 | class SearchResult { 4 | /// Total number of messages obtained 5 | int? totalCount; 6 | 7 | /// Specific search results 8 | List? searchResultItems; 9 | 10 | List? findResultItems; 11 | 12 | SearchResult({this.totalCount, this.searchResultItems}); 13 | 14 | SearchResult.fromJson(Map json) { 15 | totalCount = json['totalCount']; 16 | if (json['searchResultItems'] != null) { 17 | searchResultItems = []; 18 | json['searchResultItems'].forEach((v) { 19 | searchResultItems!.add(SearchResultItems.fromJson(v)); 20 | }); 21 | } 22 | if (json['findResultItems'] != null) { 23 | findResultItems = []; 24 | json['findResultItems'].forEach((v) { 25 | findResultItems!.add(SearchResultItems.fromJson(v)); 26 | }); 27 | } 28 | } 29 | 30 | Map toJson() { 31 | final data = Map(); 32 | data['totalCount'] = this.totalCount; 33 | if (this.searchResultItems != null) { 34 | data['searchResultItems'] = this.searchResultItems!.map((v) => v.toJson()).toList(); 35 | } 36 | if (this.findResultItems != null) { 37 | data['findResultItems'] = this.findResultItems!.map((v) => v.toJson()).toList(); 38 | } 39 | return data; 40 | } 41 | } 42 | 43 | class SearchResultItems { 44 | /// Conversation ID 45 | String? conversationID; 46 | 47 | /// Conversation type: 1 for single chat, 2 for group chat, 3 for supergroup, 4 for notification conversation 48 | int? conversationType; 49 | 50 | /// Display name 51 | String? showName; 52 | 53 | /// Profile picture 54 | String? faceURL; 55 | 56 | /// Number of messages found in this conversation 57 | int? messageCount; 58 | 59 | /// List of [Message]s 60 | List? messageList; 61 | 62 | SearchResultItems({this.conversationID, this.messageCount, this.messageList}); 63 | 64 | SearchResultItems.fromJson(Map json) { 65 | conversationID = json['conversationID']; 66 | conversationType = json['conversationType']; 67 | showName = json['showName']; 68 | faceURL = json['faceURL']; 69 | messageCount = json['messageCount']; 70 | if (json['messageList'] != null) { 71 | messageList = []; 72 | json['messageList'].forEach((v) { 73 | messageList!.add(Message.fromJson(v)); 74 | }); 75 | } 76 | } 77 | 78 | Map toJson() { 79 | final data = Map(); 80 | data['conversationID'] = this.conversationID; 81 | data['conversationType'] = this.conversationType; 82 | data['showName'] = this.showName; 83 | data['faceURL'] = this.faceURL; 84 | data['messageCount'] = this.messageCount; 85 | if (this.messageList != null) { 86 | data['messageList'] = this.messageList!.map((v) => v.toJson()).toList(); 87 | } 88 | return data; 89 | } 90 | } 91 | 92 | class SearchParams { 93 | String? conversationID; 94 | List? clientMsgIDList; 95 | 96 | SearchParams({ 97 | this.conversationID, 98 | this.clientMsgIDList, 99 | }); 100 | 101 | SearchParams.fromJson(Map json) { 102 | conversationID = json['conversationID']; 103 | if (json['clientMsgIDList'] != null) { 104 | clientMsgIDList = json['clientMsgIDList'].cast(); 105 | } 106 | } 107 | 108 | Map toJson() { 109 | final data = Map(); 110 | data['conversationID'] = this.conversationID; 111 | data['clientMsgIDList'] = this.clientMsgIDList; 112 | return data; 113 | } 114 | } 115 | 116 | class SearchFriendsInfo extends FriendInfo { 117 | late int relationship; 118 | SearchFriendsInfo({required this.relationship}) : super(); 119 | 120 | SearchFriendsInfo.fromJson(Map json) : super.fromJson(json) { 121 | relationship = json['relationship']; 122 | } 123 | 124 | Map toJson() { 125 | final data = super.toJson(); 126 | data['relationship'] = this.relationship; 127 | return data; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/listener/OnUploadFileListener.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.listener; 2 | 3 | import android.util.ArrayMap; 4 | 5 | import java.util.Map; 6 | 7 | import io.flutter.plugin.common.MethodCall; 8 | import io.flutter.plugin.common.MethodChannel; 9 | import io.openim.flutter_openim_sdk.util.CommonUtil; 10 | import open_im_sdk_callback.UploadFileCallback; 11 | 12 | public class OnUploadFileListener implements UploadFileCallback { 13 | final private MethodChannel.Result result; 14 | final private Object id; 15 | 16 | public OnUploadFileListener(MethodChannel.Result result, MethodCall call) { 17 | this.result = result; 18 | this.id = call.argument("id"); 19 | } 20 | 21 | @Override 22 | public void complete(long size, String url, long type) { 23 | if (null != id) { 24 | final Map values = new ArrayMap<>(); 25 | values.put("id", id); 26 | values.put("size", size); 27 | values.put("url", url); 28 | values.put("type", type); 29 | CommonUtil.emitEvent("uploadFileListener", "complete", values); 30 | } 31 | } 32 | 33 | @Override 34 | public void hashPartComplete(String partHash, String fileHash) { 35 | if (null != id) { 36 | final Map values = new ArrayMap<>(); 37 | values.put("id", id); 38 | values.put("partHash", partHash); 39 | values.put("fileHash", fileHash); 40 | CommonUtil.emitEvent("uploadFileListener", "hashPartComplete", values); 41 | } 42 | } 43 | 44 | @Override 45 | public void hashPartProgress(long index, long size, String partHash) { 46 | if (null != id) { 47 | final Map values = new ArrayMap<>(); 48 | values.put("id", id); 49 | values.put("index", index); 50 | values.put("size", size); 51 | values.put("partHash", partHash); 52 | CommonUtil.emitEvent("uploadFileListener", "hashPartProgress", values); 53 | } 54 | } 55 | 56 | @Override 57 | public void open(long size) { 58 | if (null != id) { 59 | final Map values = new ArrayMap<>(); 60 | values.put("id", id); 61 | values.put("size", size); 62 | CommonUtil.emitEvent("uploadFileListener", "open", values); 63 | } 64 | } 65 | 66 | @Override 67 | public void partSize(long partSize, long num) { 68 | if (null != id) { 69 | final Map values = new ArrayMap<>(); 70 | values.put("id", id); 71 | values.put("partSize", partSize); 72 | values.put("num", num); 73 | CommonUtil.emitEvent("uploadFileListener", "partSize", values); 74 | } 75 | } 76 | 77 | @Override 78 | public void uploadComplete(long fileSize, long streamSize, long storageSize) { 79 | if (null != id) { 80 | final Map values = new ArrayMap<>(); 81 | values.put("id", id); 82 | values.put("fileSize", fileSize); 83 | values.put("streamSize", streamSize); 84 | values.put("storageSize", storageSize); 85 | CommonUtil.emitEvent("uploadFileListener", "uploadProgress", values); 86 | } 87 | } 88 | 89 | @Override 90 | public void uploadID(String uploadID) { 91 | if (null != id) { 92 | final Map values = new ArrayMap<>(); 93 | values.put("id", id); 94 | values.put("uploadID", uploadID); 95 | CommonUtil.emitEvent("uploadFileListener", "uploadID", values); 96 | } 97 | } 98 | 99 | @Override 100 | public void uploadPartComplete(long index, long partSize, String partHash) { 101 | if (null != id) { 102 | final Map values = new ArrayMap<>(); 103 | values.put("id", id); 104 | values.put("index", index); 105 | values.put("partSize", partSize); 106 | values.put("partHash", partHash); 107 | CommonUtil.emitEvent("uploadFileListener", "uploadPartComplete", values); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 38 | 39 | 40 | 41 | 44 | 50 | 51 | 52 | 53 | 54 | 66 | 68 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_openim_sdk_example 2 | description: Demonstrates how to use the flutter_openim_sdk plugin. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | # In Windows, build-name is used as the major, minor, and patch parts 19 | # of the product and file versions while build-number is used as the build suffix. 20 | version: 1.0.0+1 21 | 22 | environment: 23 | sdk: '>=3.4.4 <4.0.0' 24 | 25 | # Dependencies specify other packages that your package needs in order to work. 26 | # To automatically upgrade your package dependencies to the latest versions 27 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 28 | # dependencies can be manually updated by changing the version numbers below to 29 | # the latest version available on pub.dev. To see which dependencies have newer 30 | # versions available, run `flutter pub outdated`. 31 | dependencies: 32 | flutter: 33 | sdk: flutter 34 | 35 | flutter_openim_sdk: 36 | # When depending on this package from a real application you should use: 37 | # flutter_openim_sdk: ^x.y.z 38 | # See https://dart.dev/tools/pub/dependencies#version-constraints 39 | # The example app is bundled with the plugin so we use a path dependency on 40 | # the parent directory to use the current plugin's version. 41 | path: ../ 42 | 43 | # The following adds the Cupertino Icons font to your application. 44 | # Use with the CupertinoIcons class for iOS style icons. 45 | cupertino_icons: ^1.0.6 46 | 47 | dev_dependencies: 48 | flutter_test: 49 | sdk: flutter 50 | 51 | # The "flutter_lints" package below contains a set of recommended lints to 52 | # encourage good coding practices. The lint set provided by the package is 53 | # activated in the `analysis_options.yaml` file located at the root of your 54 | # package. See that file for information about deactivating specific lint 55 | # rules and activating additional ones. 56 | flutter_lints: ^3.0.0 57 | 58 | # For information on the generic Dart part of this file, see the 59 | # following page: https://dart.dev/tools/pub/pubspec 60 | 61 | # The following section is specific to Flutter packages. 62 | flutter: 63 | 64 | # The following line ensures that the Material Icons font is 65 | # included with your application, so that you can use the icons in 66 | # the material Icons class. 67 | uses-material-design: true 68 | 69 | # To add assets to your application, add an assets section, like this: 70 | # assets: 71 | # - images/a_dot_burr.jpeg 72 | # - images/a_dot_ham.jpeg 73 | 74 | # An image asset can refer to one or more resolution-specific "variants", see 75 | # https://flutter.dev/assets-and-images/#resolution-aware 76 | 77 | # For details regarding adding assets from package dependencies, see 78 | # https://flutter.dev/assets-and-images/#from-packages 79 | 80 | # To add custom fonts to your application, add a fonts section here, 81 | # in this "flutter" section. Each entry in this list should have a 82 | # "family" key with the font family name, and a "fonts" key with a 83 | # list giving the asset and other descriptors for the font. For 84 | # example: 85 | # fonts: 86 | # - family: Schyler 87 | # fonts: 88 | # - asset: fonts/Schyler-Regular.ttf 89 | # - asset: fonts/Schyler-Italic.ttf 90 | # style: italic 91 | # - family: Trajan Pro 92 | # fonts: 93 | # - asset: fonts/TrajanPro.ttf 94 | # - asset: fonts/TrajanPro_Bold.ttf 95 | # weight: 700 96 | # 97 | # For details regarding fonts from package dependencies, 98 | # see https://flutter.dev/custom-fonts/#from-packages 99 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/manager/IMManager.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.manager; 2 | 3 | import io.flutter.plugin.common.MethodCall; 4 | import io.flutter.plugin.common.MethodChannel; 5 | import io.openim.flutter_openim_sdk.FlutterOpenimSdkPlugin; 6 | import io.openim.flutter_openim_sdk.listener.OnBaseListener; 7 | import io.openim.flutter_openim_sdk.listener.OnConnListener; 8 | import io.openim.flutter_openim_sdk.listener.OnUploadFileListener; 9 | import io.openim.flutter_openim_sdk.listener.OnUploadLogsListener; 10 | import io.openim.flutter_openim_sdk.util.CommonUtil; 11 | import open_im_sdk.Open_im_sdk; 12 | 13 | public class IMManager extends BaseManager { 14 | 15 | public void initSDK(MethodCall methodCall, MethodChannel.Result result) { 16 | boolean initialized = Open_im_sdk.initSDK( 17 | new OnConnListener(), 18 | value(methodCall, "operationID"), 19 | jsonValue(methodCall)); 20 | FlutterOpenimSdkPlugin.isInitialized = initialized; 21 | CommonUtil.runMainThreadReturn(result, initialized); 22 | } 23 | 24 | public void unInitSDK(MethodCall methodCall, MethodChannel.Result result) { 25 | Open_im_sdk.unInitSDK(value(methodCall, "operationID")); 26 | } 27 | 28 | public void login(MethodCall methodCall, MethodChannel.Result result) { 29 | Open_im_sdk.login( 30 | new OnBaseListener(result, methodCall), 31 | value(methodCall, "operationID"), 32 | value(methodCall, "userID"), 33 | value(methodCall, "token") 34 | ); 35 | } 36 | 37 | public void logout(MethodCall methodCall, MethodChannel.Result result) { 38 | Open_im_sdk.logout( 39 | new OnBaseListener(result, methodCall), 40 | value(methodCall, "operationID") 41 | ); 42 | } 43 | 44 | public void getLoginStatus(MethodCall methodCall, MethodChannel.Result result) { 45 | CommonUtil.runMainThreadReturn(result, Open_im_sdk.getLoginStatus(value(methodCall, "operationID"))); 46 | } 47 | 48 | public void uploadFile(MethodCall methodCall, MethodChannel.Result result) { 49 | Open_im_sdk.uploadFile( 50 | new OnBaseListener(result, methodCall), 51 | value(methodCall, "operationID"), 52 | jsonValue(methodCall), 53 | new OnUploadFileListener(result, methodCall) 54 | ); 55 | } 56 | 57 | public void updateFcmToken(MethodCall methodCall, MethodChannel.Result result) { 58 | Open_im_sdk.updateFcmToken( 59 | new OnBaseListener(result, methodCall), 60 | value(methodCall, "operationID"), 61 | value(methodCall, "fcmToken"), 62 | int2long(methodCall, "expireTime") 63 | ); 64 | } 65 | 66 | public void uploadLogs(MethodCall methodCall, MethodChannel.Result result) { 67 | Open_im_sdk.uploadLogs( 68 | new OnBaseListener(result, methodCall), 69 | value(methodCall, "operationID"), 70 | int2long(methodCall, "line"), 71 | value(methodCall, "ex"), 72 | new OnUploadLogsListener(result, methodCall) 73 | ); 74 | } 75 | 76 | public void logs(MethodCall methodCall, MethodChannel.Result result) { 77 | Open_im_sdk.logs( 78 | new OnBaseListener(result, methodCall), 79 | value(methodCall, "operationID"), 80 | int2long(methodCall, "logLevel"), 81 | value(methodCall, "file"), 82 | int2long(methodCall, "line"), 83 | value(methodCall, "msgs"), 84 | value(methodCall, "err"), 85 | value(methodCall, "keyAndValue") 86 | ); 87 | } 88 | 89 | public void setAppBackgroundStatus(MethodCall methodCall, MethodChannel.Result result) { 90 | Open_im_sdk.setAppBackgroundStatus( 91 | new OnBaseListener(result, methodCall), 92 | value(methodCall, "operationID"), 93 | value(methodCall, "isBackground") 94 | ); 95 | } 96 | 97 | 98 | public void networkStatusChanged(MethodCall methodCall, MethodChannel.Result result) { 99 | Open_im_sdk.networkStatusChanged( 100 | new OnBaseListener(result, methodCall), 101 | value(methodCall, "operationID") 102 | ); 103 | } 104 | 105 | // public void setListenerForService(MethodCall methodCall, MethodChannel.Result result) { 106 | // Open_im_sdk.setListenerForService(new OnListenerForService()); 107 | // 108 | // result.success(null); 109 | // } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /lib/src/manager/im_user_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 3 | 4 | class UserManager { 5 | MethodChannel _channel; 6 | late OnUserListener listener; 7 | 8 | UserManager(this._channel); 9 | 10 | /// User profile change listener 11 | Future setUserListener(OnUserListener listener) { 12 | this.listener = listener; 13 | return _channel.invokeMethod('setUserListener', _buildParam({})); 14 | } 15 | 16 | /// Get user information 17 | /// [userIDList] List of user IDs 18 | Future> getUsersInfo({ 19 | required List userIDList, 20 | String? operationID, 21 | }) => 22 | _channel 23 | .invokeMethod( 24 | 'getUsersInfo', 25 | _buildParam({ 26 | 'userIDList': userIDList, 27 | 'operationID': Utils.checkOperationID(operationID), 28 | })) 29 | .then((value) => Utils.toList(value, (v) => PublicUserInfo.fromJson(v))); 30 | 31 | /// Get information of the currently logged-in user 32 | Future getSelfUserInfo({ 33 | String? operationID, 34 | }) => 35 | _channel 36 | .invokeMethod( 37 | 'getSelfUserInfo', 38 | _buildParam({ 39 | 'operationID': Utils.checkOperationID(operationID), 40 | })) 41 | .then((value) => Utils.toObj(value, (map) => UserInfo.fromJson(map))); 42 | 43 | /// Modify the profile of the currently logged-in user 44 | /// [nickname] Nickname 45 | /// [faceURL] Profile picture 46 | /// [appManagerLevel] 47 | /// [ex] Additional fields 48 | Future setSelfInfo({ 49 | String? nickname, 50 | String? faceURL, 51 | int? globalRecvMsgOpt, 52 | String? ex, 53 | String? operationID, 54 | }) => 55 | _channel.invokeMethod( 56 | 'setSelfInfo', 57 | _buildParam({ 58 | 'nickname': nickname, 59 | 'faceURL': faceURL, 60 | 'globalRecvMsgOpt': globalRecvMsgOpt, 61 | 'ex': ex, 62 | 'operationID': Utils.checkOperationID(operationID), 63 | })); 64 | 65 | Future> subscribeUsersStatus( 66 | List userIDs, { 67 | String? operationID, 68 | }) { 69 | return _channel 70 | .invokeMethod( 71 | 'subscribeUsersStatus', 72 | _buildParam({ 73 | 'userIDs': userIDs, 74 | 'operationID': Utils.checkOperationID(operationID), 75 | })) 76 | .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); 77 | } 78 | 79 | Future unsubscribeUsersStatus( 80 | List userIDs, { 81 | String? operationID, 82 | }) { 83 | return _channel.invokeMethod( 84 | 'unsubscribeUsersStatus', 85 | _buildParam({ 86 | 'userIDs': userIDs, 87 | 'operationID': Utils.checkOperationID(operationID), 88 | })); 89 | } 90 | 91 | Future> getSubscribeUsersStatus({ 92 | String? operationID, 93 | }) { 94 | return _channel 95 | .invokeMethod( 96 | 'getSubscribeUsersStatus', 97 | _buildParam({ 98 | 'operationID': Utils.checkOperationID(operationID), 99 | })) 100 | .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); 101 | } 102 | 103 | Future> getUserStatus( 104 | List userIDs, { 105 | String? operationID, 106 | }) { 107 | return _channel 108 | .invokeMethod( 109 | 'getUserStatus', 110 | _buildParam({ 111 | 'userIDs': userIDs, 112 | 'operationID': Utils.checkOperationID(operationID), 113 | })) 114 | .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); 115 | } 116 | 117 | @Deprecated('Use [getUsersInfo] instead') 118 | Future> getUsersInfoWithCache( 119 | List userIDs, { 120 | String? operationID, 121 | }) { 122 | return getUsersInfo(userIDList: userIDs, operationID: operationID); 123 | } 124 | 125 | /// Global Do Not Disturb 126 | /// [status] 0: Normal; 1: Do not accept messages; 2: Accept online messages but not offline messages; 127 | @Deprecated('use [setSelfInfo] instead') 128 | Future setGlobalRecvMessageOpt({ 129 | required int status, 130 | String? operationID, 131 | }) { 132 | return setSelfInfo(globalRecvMsgOpt: status); 133 | } 134 | 135 | static Map _buildParam(Map param) { 136 | param["ManagerName"] = "userManager"; 137 | param = Utils.cleanMap(param); 138 | 139 | return param; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /lib/src/enum/message_type.dart: -------------------------------------------------------------------------------- 1 | /// Message Types 2 | class MessageType { 3 | /// Normal text 4 | static const text = 101; 5 | 6 | /// Picture 7 | static const picture = 102; 8 | 9 | /// Voice 10 | static const voice = 103; 11 | 12 | /// Video 13 | static const video = 104; 14 | 15 | /// File 16 | static const file = 105; 17 | 18 | /// @ Message 19 | static const atText = 106; 20 | 21 | /// Merge 22 | static const merger = 107; 23 | 24 | /// Business Card 25 | static const card = 108; 26 | 27 | /// Location 28 | static const location = 109; 29 | 30 | /// Custom 31 | static const custom = 110; 32 | 33 | /// Typing 34 | static const typing = 113; 35 | 36 | /// Quote Reply 37 | static const quote = 114; 38 | 39 | /// Custom Emoji 40 | static const customFace = 115; 41 | 42 | /// Group Message Has Read Receipt (Deprecated in v3) 43 | @Deprecated('Use GroupHasReadReceiptNotification instead') 44 | static const groupHasReadReceipt = 116; 45 | 46 | /// Rich Text Message 47 | static const advancedText = 117; 48 | 49 | static const customMsgNotTriggerConversation = 119; 50 | 51 | static const customMsgOnlineOnly = 120; 52 | 53 | /// Notification Types 54 | static const notificationBegin = 1000; 55 | 56 | static const friendNotificationBegin = 1200; 57 | 58 | /// Friend Request Accepted 59 | static const friendApplicationApprovedNotification = 1201; 60 | 61 | /// Friend Request Rejected 62 | static const friendApplicationRejectedNotification = 1202; 63 | 64 | /// Friend Request 65 | static const friendApplicationNotification = 1203; 66 | 67 | /// Friend Added 68 | static const friendAddedNotification = 1204; 69 | 70 | /// Friend Deleted 71 | static const friendDeletedNotification = 1205; 72 | 73 | /// Set Friend Remark 74 | static const friendRemarkSetNotification = 1206; 75 | 76 | /// Friend Added to Blacklist 77 | static const blackAddedNotification = 1207; 78 | 79 | /// Removed from Blacklist 80 | static const blackDeletedNotification = 1208; 81 | 82 | static const friendNotificationEnd = 1299; 83 | 84 | /// Conversation Change 85 | static const conversationChangeNotification = 1300; 86 | 87 | static const userNotificationBegin = 1301; 88 | 89 | /// User Information Changed 90 | static const userInfoUpdatedNotification = 1303; 91 | 92 | static const userNotificationEnd = 1399; 93 | 94 | /// OA Notification 95 | static const oaNotification = 1400; 96 | 97 | static const groupNotificationBegin = 1500; 98 | 99 | /// Group Created 100 | static const groupCreatedNotification = 1501; 101 | 102 | /// Group Info Set 103 | static const groupInfoSetNotification = 1502; 104 | 105 | /// Join Group Application 106 | static const joinGroupApplicationNotification = 1503; 107 | 108 | /// Group Member Quit 109 | static const memberQuitNotification = 1504; 110 | 111 | /// Group Application Accepted 112 | static const groupApplicationAcceptedNotification = 1505; 113 | 114 | /// Group Application Rejected 115 | static const groupApplicationRejectedNotification = 1506; 116 | 117 | /// Group Owner Transferred 118 | static const groupOwnerTransferredNotification = 1507; 119 | 120 | /// Member Kicked from Group 121 | static const memberKickedNotification = 1508; 122 | 123 | /// Member Invited to Group 124 | static const memberInvitedNotification = 1509; 125 | 126 | /// Member Entered Group 127 | static const memberEnterNotification = 1510; 128 | 129 | /// Dismiss Group 130 | static const dismissGroupNotification = 1511; 131 | 132 | static const groupNotificationEnd = 1599; 133 | 134 | /// Group Member Muted 135 | static const groupMemberMutedNotification = 1512; 136 | 137 | /// Group Member Cancel Muted 138 | static const groupMemberCancelMutedNotification = 1513; 139 | 140 | /// Group Muted 141 | static const groupMutedNotification = 1514; 142 | 143 | /// Cancel Group Muted 144 | static const groupCancelMutedNotification = 1515; 145 | 146 | /// Group Member Information Changed 147 | static const groupMemberInfoChangedNotification = 1516; 148 | 149 | /// Group Member Set to Admin 150 | static const groupMemberSetToAdminNotification = 1517; 151 | 152 | static const groupMemberSetToOrdinaryUserNotification = 1518; 153 | 154 | /// Group Notice Changed 155 | static const groupInfoSetAnnouncementNotification = 1519; 156 | 157 | /// Group Name Changed 158 | static const groupInfoSetNameNotification = 1520; 159 | 160 | /// Burn After Reading 161 | static const burnAfterReadingNotification = 1701; 162 | 163 | static const notificationEnd = 2000; 164 | 165 | /// Business Notification 166 | static const businessNotification = 2001; 167 | 168 | /// Recall Message 169 | static const revokeMessageNotification = 2101; 170 | 171 | /// Single Chat Has Read Receipt 172 | static const signalHasReadReceiptNotification = 2150; 173 | 174 | /// Group Chat Has Read Receipt 175 | static const groupHasReadReceiptNotification = 2155; 176 | } 177 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/FlutterOpenimSdkPlugin.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | import java.lang.reflect.Field; 9 | import java.lang.reflect.Method; 10 | 11 | import io.flutter.Log; 12 | import io.flutter.embedding.engine.plugins.FlutterPlugin; 13 | import io.flutter.embedding.engine.plugins.activity.ActivityAware; 14 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; 15 | import io.flutter.plugin.common.MethodCall; 16 | import io.flutter.plugin.common.MethodChannel; 17 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler; 18 | import io.flutter.plugin.common.MethodChannel.Result; 19 | import io.openim.flutter_openim_sdk.connectivity.ConnectivityListener; 20 | import io.openim.flutter_openim_sdk.connectivity.VisibilityListener; 21 | import io.openim.flutter_openim_sdk.manager.ConversationManager; 22 | import io.openim.flutter_openim_sdk.manager.FriendshipManager; 23 | import io.openim.flutter_openim_sdk.manager.GroupManager; 24 | import io.openim.flutter_openim_sdk.manager.IMManager; 25 | import io.openim.flutter_openim_sdk.manager.MessageManager; 26 | import io.openim.flutter_openim_sdk.manager.UserManager; 27 | 28 | 29 | /** 30 | * FlutterOpenimSdkPlugin 31 | */ 32 | public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler, ActivityAware { 33 | /// The MethodChannel that will the communication between Flutter and native Android 34 | /// 35 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it 36 | /// when the Flutter Engine is detached from the Activity 37 | private static final String CHANNEL_NAME = "flutter_openim_sdk"; 38 | public static MethodChannel channel; 39 | private static IMManager imManager; 40 | private static UserManager userManager; 41 | private static FriendshipManager friendshipManager; 42 | private static MessageManager messageManager; 43 | private static ConversationManager conversationManager; 44 | private static GroupManager groupManager; 45 | private static Activity activity; 46 | private static Context context; 47 | private ConnectivityListener connectivityListener; 48 | private VisibilityListener visibilityListener; 49 | public static boolean isInitialized; 50 | 51 | public FlutterOpenimSdkPlugin() { 52 | FlutterOpenimSdkPlugin.imManager = new IMManager(); 53 | FlutterOpenimSdkPlugin.userManager = new UserManager(); 54 | FlutterOpenimSdkPlugin.friendshipManager = new FriendshipManager(); 55 | FlutterOpenimSdkPlugin.messageManager = new MessageManager(); 56 | FlutterOpenimSdkPlugin.conversationManager = new ConversationManager(); 57 | FlutterOpenimSdkPlugin.groupManager = new GroupManager(); 58 | } 59 | 60 | 61 | @Override 62 | public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { 63 | channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), CHANNEL_NAME); 64 | context = flutterPluginBinding.getApplicationContext(); 65 | channel.setMethodCallHandler(this); 66 | connectivityListener = new ConnectivityListener(context); 67 | visibilityListener = new VisibilityListener(); 68 | connectivityListener.register(); 69 | } 70 | 71 | @Override 72 | public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { 73 | parse(call, result); 74 | } 75 | 76 | @Override 77 | public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { 78 | FlutterOpenimSdkPlugin.channel.setMethodCallHandler(null); 79 | connectivityListener.unregisterReceiver(); 80 | } 81 | 82 | 83 | @Override 84 | public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { 85 | visibilityListener.register(activity = binding.getActivity()); 86 | } 87 | 88 | @Override 89 | public void onDetachedFromActivityForConfigChanges() { 90 | visibilityListener.unregisterReceiver(activity); 91 | activity = null; 92 | } 93 | 94 | @Override 95 | public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) { 96 | visibilityListener.register(activity = binding.getActivity()); 97 | } 98 | 99 | @Override 100 | public void onDetachedFromActivity() { 101 | visibilityListener.unregisterReceiver(activity); 102 | activity = null; 103 | } 104 | 105 | void parse(@NonNull MethodCall call, @NonNull Result result) { 106 | try { 107 | String managerName = call.argument("ManagerName"); 108 | Field field = FlutterOpenimSdkPlugin.class.getDeclaredField(managerName); 109 | Method method = field.get(new Object()).getClass().getDeclaredMethod(call.method, MethodCall.class, Result.class); 110 | Log.i("F-OpenIMSDK(flutter call native)", "{ class:" + managerName + ", method:" + method.getName() + " }"); 111 | method.invoke(field.get(new Object()), call, result); 112 | } catch (Exception e) { 113 | e.printStackTrace(); 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /.idea/flutter_openim_sdk.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /lib/src/enum/sdk_error_code.dart: -------------------------------------------------------------------------------- 1 | /// SDK Error Codes 2 | class SDKErrorCode { 3 | /// Network Request Error 4 | static const int networkRequestError = 10000; 5 | 6 | /// Network Waiting Timeout Error 7 | static const int networkWaitTimeoutError = 10001; 8 | 9 | /// Parameter Error 10 | static const int parameterError = 10002; 11 | 12 | /// Context Timeout Error, usually when the user has already logged out 13 | static const int contextTimeoutError = 10003; 14 | 15 | /// Resources not loaded completely, usually uninitialized or login hasn't completed 16 | static const int resourceNotLoaded = 10004; 17 | 18 | /// Unknown Error, check the error message for details 19 | static const int unknownError = 10005; 20 | 21 | /// SDK Internal Error, check the error message for details 22 | static const int sdkInternalError = 10006; 23 | 24 | /// This user has set not to be added 25 | static const int refuseToAddFriends = 10013; 26 | 27 | /// User does not exist or is not registered 28 | static const int userNotExistOrNotRegistered = 10100; 29 | 30 | /// User has already logged out 31 | static const int userHasLoggedOut = 10101; 32 | 33 | /// User is attempting to log in again, check the login status to avoid duplicate logins 34 | static const int repeatLogin = 10102; 35 | 36 | /// The file to upload does not exist 37 | static const int uploadFileNotExist = 10200; 38 | 39 | /// Message decompression failed 40 | static const int messageDecompressionFailed = 10201; 41 | 42 | /// Message decoding failed 43 | static const int messageDecodingFailed = 10202; 44 | 45 | /// Unsupported long connection binary protocol 46 | static const int unsupportedLongConnection = 10203; 47 | 48 | /// Message sent multiple times 49 | static const int messageRepeated = 10204; 50 | 51 | /// Message content type not supported 52 | static const int messageContentTypeNotSupported = 10205; 53 | 54 | /// Unsupported session operation 55 | static const int unsupportedSessionOperation = 10301; 56 | 57 | /// Group ID does not exist 58 | static const int groupIDNotExist = 10400; 59 | 60 | /// Group type is incorrect 61 | static const int wrongGroupType = 10401; 62 | 63 | /// Server Internal Error, usually an internal network error, check if server nodes are running correctly 64 | static const int serverInternalError = 500; 65 | 66 | /// Parameter Error on the server, check if body and header parameters are correct 67 | static const int serverParameterError = 1001; 68 | 69 | /// Insufficient Permissions, typically when the token in the header is incorrect or when trying to perform unauthorized actions 70 | static const int insufficientPermissions = 1002; 71 | 72 | /// Duplicate Database Primary Key 73 | static const int duplicateDatabasePrimaryKey = 1003; 74 | 75 | /// Database Record Not Found 76 | static const int databaseRecordNotFound = 1004; 77 | 78 | /// User ID does not exist 79 | static const int userIDNotExist = 1101; 80 | 81 | /// User is already registered 82 | static const int userAlreadyRegistered = 1102; 83 | 84 | /// Group does not exist 85 | static const int groupNotExis = 1201; 86 | 87 | /// Group already exists 88 | static const int groupAlreadyExists = 1202; 89 | 90 | /// User is not in the group 91 | static const int userIsNotInGroup = 1203; 92 | 93 | /// Group has been disbanded 94 | static const int groupDisbanded = 1204; 95 | 96 | /// Group application has already been processed, no need to process it again 97 | static const int groupApplicationHasBeenProcessed = 1206; 98 | 99 | /// Cannot add yourself as a friend 100 | static const int notAddMyselfAsAFriend = 1301; 101 | 102 | /// You have been blocked by the other party 103 | static const int hasBeenBlocked = 1302; 104 | 105 | /// The other party is not your friend 106 | static const int notFriend = 1303; 107 | 108 | /// Already in a friend relationship, no need to reapply 109 | static const int alreadyAFriendRelationship = 1304; 110 | 111 | /// Message read function is turned off 112 | static const int messageReadFunctionIsTurnedOff = 1401; 113 | 114 | /// You have been banned from speaking in the group 115 | static const int youHaveBeenBanned = 1402; 116 | 117 | /// The group has been banned from posting 118 | static const int groupHasBeenBanned = 1403; 119 | 120 | /// This message has been retracted 121 | static const int messageHasBeenRetracted = 1404; 122 | 123 | /// Authorization has expired 124 | static const int licenseExpired = 1405; 125 | 126 | /// Token has expired 127 | static const int tokenHasExpired = 1501; 128 | 129 | /// Invalid token 130 | static const int tokenInvalid = 1502; 131 | 132 | /// Token format error 133 | static const int tokenFormatError = 1503; 134 | 135 | /// Token has not yet taken effect 136 | static const int tokenHasNotYetTakenEffect = 1504; 137 | 138 | /// Unknown token error 139 | static const int unknownTokenError = 1505; 140 | 141 | /// The kicked-out token is invalid 142 | static const int thekickedOutTokenIsInvalid = 1506; 143 | 144 | /// Token does not exist 145 | static const int tokenNotExist = 1507; 146 | 147 | /// Number of Connections Exceeds Gateway's Maximum Limit 148 | static const int connectionsExceedsMaximumLimit = 1601; 149 | 150 | /// Handshake Parameter Error 151 | static const int handshakeParameterError = 1602; 152 | 153 | /// File Upload Expired 154 | static const int fileUploadExpired = 1701; 155 | } 156 | -------------------------------------------------------------------------------- /lib/src/models/conversation_info.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; 4 | 5 | class ConversationInfo { 6 | // Unique identifier for the conversation 7 | String conversationID; 8 | 9 | // Type of the conversation (e.g., single, group, super group) 10 | int? conversationType; 11 | 12 | // User ID in case of a single chat 13 | String? userID; 14 | 15 | // Group ID in case of a group chat 16 | String? groupID; 17 | 18 | // Display name or nickname 19 | String? showName; 20 | 21 | // URL of the user's or group's profile picture 22 | String? faceURL; 23 | 24 | // Message reception option (0: normal, 1: do not accept messages, 2: accept online messages but not offline messages) 25 | int? recvMsgOpt; 26 | 27 | // Number of unread messages in the conversation 28 | int unreadCount = 0; 29 | 30 | // Latest message in the conversation 31 | Message? latestMsg; 32 | 33 | // Timestamp of the latest message 34 | int? latestMsgSendTime; 35 | 36 | // Draft text for the conversation 37 | String? draftText; 38 | 39 | // Timestamp when the draft text was created 40 | int? draftTextTime; 41 | 42 | // Indicates whether the conversation is pinned 43 | bool? isPinned; 44 | 45 | // Indicates whether the conversation is a private chat with features like self-destructing messages 46 | bool? isPrivateChat; 47 | 48 | // Duration for which messages are readable (in seconds) 49 | int? burnDuration; 50 | 51 | // Indicates whether the conversation has self-destructing messages enabled 52 | bool? isMsgDestruct; 53 | 54 | // Timestamp for self-destructing messages (in seconds) 55 | int? msgDestructTime; 56 | 57 | // Additional data or metadata 58 | String? ex; 59 | 60 | // Indicates whether the user is no longer in the group (if applicable) 61 | bool? isNotInGroup; 62 | 63 | // Group @ type, which includes @ all, @ individual, and announcement prompts 64 | int? groupAtType; 65 | 66 | // Constructor to create a ConversationInfo object 67 | ConversationInfo({ 68 | required this.conversationID, 69 | this.conversationType, 70 | this.userID, 71 | this.groupID, 72 | this.showName, 73 | this.faceURL, 74 | this.recvMsgOpt, 75 | this.unreadCount = 0, 76 | this.latestMsg, 77 | this.latestMsgSendTime, 78 | this.draftText, 79 | this.draftTextTime, 80 | this.isPrivateChat, 81 | this.burnDuration, 82 | this.isPinned, 83 | this.isNotInGroup, 84 | this.ex, 85 | this.groupAtType, 86 | this.isMsgDestruct, 87 | this.msgDestructTime, 88 | }); 89 | 90 | ConversationInfo.fromJson(Map json) : conversationID = json['conversationID'] { 91 | conversationType = json['conversationType']; 92 | userID = json['userID']; 93 | groupID = json['groupID']; 94 | showName = json['showName']; 95 | faceURL = json['faceURL']; 96 | recvMsgOpt = json['recvMsgOpt']; 97 | unreadCount = json['unreadCount']; 98 | try { 99 | if (json['latestMsg'] is String) { 100 | latestMsg = Message.fromJson(jsonDecode(json['latestMsg'])); 101 | } else if (json['latestMsg'] is Map) { 102 | latestMsg = Message.fromJson(json['latestMsg']); 103 | } 104 | } catch (e) {} 105 | latestMsgSendTime = json['latestMsgSendTime']; 106 | draftText = json['draftText']; 107 | draftTextTime = json['draftTextTime']; 108 | isPinned = json['isPinned']; 109 | isPrivateChat = json['isPrivateChat']; 110 | burnDuration = json['burnDuration']; 111 | isNotInGroup = json['isNotInGroup']; 112 | groupAtType = json['groupAtType']; 113 | ex = json['ex']; 114 | isMsgDestruct = json['isMsgDestruct']; 115 | msgDestructTime = json['msgDestructTime']; 116 | } 117 | 118 | // Method to convert the ConversationInfo object to a JSON map 119 | Map toJson() { 120 | final data = Map(); 121 | data['conversationID'] = this.conversationID; 122 | data['conversationType'] = this.conversationType; 123 | data['userID'] = this.userID; 124 | data['groupID'] = this.groupID; 125 | data['showName'] = this.showName; 126 | data['faceURL'] = this.faceURL; 127 | data['recvMsgOpt'] = this.recvMsgOpt; 128 | data['unreadCount'] = this.unreadCount; 129 | data['latestMsg'] = this.latestMsg?.toJson(); 130 | data['latestMsgSendTime'] = this.latestMsgSendTime; 131 | data['draftText'] = this.draftText; 132 | data['draftTextTime'] = this.draftTextTime; 133 | data['isPinned'] = this.isPinned; 134 | data['isPrivateChat'] = this.isPrivateChat; 135 | data['burnDuration'] = this.burnDuration; 136 | data['isNotInGroup'] = this.isNotInGroup; 137 | data['groupAtType'] = this.groupAtType; 138 | data['ex'] = this.ex; 139 | data['isMsgDestruct'] = this.isMsgDestruct; 140 | data['msgDestructTime'] = this.msgDestructTime; 141 | return data; 142 | } 143 | 144 | // Check if it's a single chat 145 | bool get isSingleChat => conversationType == ConversationType.single; 146 | 147 | // Check if it's a group chat 148 | bool get isGroupChat => conversationType == ConversationType.group || conversationType == ConversationType.superGroup; 149 | 150 | // Check if it's a valid conversation (not in a group if isNotInGroup is true) 151 | bool get isValid => isSingleChat || (isGroupChat && !isNotInGroup!); 152 | 153 | @override 154 | bool operator ==(Object other) => 155 | identical(this, other) || other is ConversationInfo && runtimeType == other.runtimeType && conversationID == other.conversationID; 156 | 157 | @override 158 | int get hashCode => conversationID.hashCode; 159 | } 160 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/manager/FriendshipManager.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.manager; 2 | 3 | import io.flutter.plugin.common.MethodCall; 4 | import io.flutter.plugin.common.MethodChannel; 5 | import io.openim.flutter_openim_sdk.listener.OnBaseListener; 6 | import io.openim.flutter_openim_sdk.listener.OnFriendshipListener; 7 | import open_im_sdk.Open_im_sdk; 8 | 9 | public class FriendshipManager extends BaseManager { 10 | 11 | 12 | public void setFriendListener(MethodCall methodCall, MethodChannel.Result result) { 13 | Open_im_sdk.setFriendListener(new OnFriendshipListener()); 14 | 15 | result.success(null); 16 | } 17 | 18 | public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) { 19 | Open_im_sdk.getSpecifiedFriendsInfo( 20 | new OnBaseListener(result, methodCall), 21 | value(methodCall, "operationID"), 22 | jsonValue(methodCall, "userIDList"), 23 | value(methodCall, "filterBlack") 24 | ); 25 | } 26 | 27 | public void addFriend(MethodCall methodCall, MethodChannel.Result result) { 28 | Open_im_sdk.addFriend( 29 | new OnBaseListener(result, methodCall), 30 | value(methodCall, "operationID"), 31 | jsonValue(methodCall) 32 | ); 33 | } 34 | 35 | public void getFriendApplicationListAsRecipient(MethodCall methodCall, MethodChannel.Result result) { 36 | Open_im_sdk.getFriendApplicationListAsRecipient( 37 | new OnBaseListener(result, methodCall), 38 | value(methodCall, "operationID"), 39 | jsonValue(methodCall, "req") 40 | ); 41 | } 42 | 43 | public void getFriendApplicationListAsApplicant(MethodCall methodCall, MethodChannel.Result result) { 44 | Open_im_sdk.getFriendApplicationListAsApplicant( 45 | new OnBaseListener(result, methodCall), 46 | value(methodCall, "operationID"), 47 | jsonValue(methodCall, "req") 48 | ); 49 | } 50 | 51 | public void getFriendList(MethodCall methodCall, MethodChannel.Result result) { 52 | Open_im_sdk.getFriendList( 53 | new OnBaseListener(result, methodCall), 54 | value(methodCall, "operationID"), 55 | value(methodCall, "filterBlack") 56 | ); 57 | } 58 | 59 | public void getFriendListPage(MethodCall methodCall, MethodChannel.Result result) { 60 | Open_im_sdk.getFriendListPage( 61 | new OnBaseListener(result, methodCall), 62 | value(methodCall, "operationID"), 63 | value(methodCall, "offset"), 64 | value(methodCall, "count"), 65 | value(methodCall, "filterBlack") 66 | ); 67 | } 68 | 69 | public void addBlacklist(MethodCall methodCall, MethodChannel.Result result) { 70 | Open_im_sdk.addBlack( 71 | new OnBaseListener(result, methodCall), 72 | value(methodCall, "operationID"), 73 | value(methodCall, "userID"), 74 | value(methodCall, "ex") 75 | ); 76 | } 77 | 78 | public void getBlacklist(MethodCall methodCall, MethodChannel.Result result) { 79 | Open_im_sdk.getBlackList( 80 | new OnBaseListener(result, methodCall), 81 | value(methodCall, "operationID") 82 | ); 83 | } 84 | 85 | public void removeBlacklist(MethodCall methodCall, MethodChannel.Result result) { 86 | Open_im_sdk.removeBlack( 87 | new OnBaseListener(result, methodCall), 88 | value(methodCall, "operationID"), 89 | value(methodCall, "userID") 90 | ); 91 | } 92 | 93 | public void checkFriend(MethodCall methodCall, MethodChannel.Result result) { 94 | Open_im_sdk.checkFriend( 95 | new OnBaseListener(result, methodCall), 96 | value(methodCall, "operationID"), 97 | jsonValue(methodCall, "userIDList") 98 | ); 99 | } 100 | 101 | public void deleteFriend(MethodCall methodCall, MethodChannel.Result result) { 102 | Open_im_sdk.deleteFriend( 103 | new OnBaseListener(result, methodCall), 104 | value(methodCall, "operationID"), 105 | value(methodCall, "userID") 106 | ); 107 | } 108 | 109 | public void acceptFriendApplication(MethodCall methodCall, MethodChannel.Result result) { 110 | Open_im_sdk.acceptFriendApplication( 111 | new OnBaseListener(result, methodCall), 112 | value(methodCall, "operationID"), 113 | jsonValue(methodCall) 114 | ); 115 | } 116 | 117 | public void refuseFriendApplication(MethodCall methodCall, MethodChannel.Result result) { 118 | Open_im_sdk.refuseFriendApplication( 119 | new OnBaseListener(result, methodCall), 120 | value(methodCall, "operationID"), 121 | jsonValue(methodCall) 122 | ); 123 | } 124 | 125 | public void searchFriends(MethodCall methodCall, MethodChannel.Result result) { 126 | Open_im_sdk.searchFriends( 127 | new OnBaseListener(result, methodCall), 128 | value(methodCall, "operationID"), 129 | jsonValue(methodCall, "searchParam") 130 | ); 131 | } 132 | 133 | public void updateFriends(MethodCall methodCall, MethodChannel.Result result) { 134 | Open_im_sdk.updateFriends( 135 | new OnBaseListener(result, methodCall), 136 | value(methodCall, "operationID"), 137 | jsonValue(methodCall, "req") 138 | ); 139 | } 140 | 141 | public void getFriendApplicationUnhandledCount(MethodCall methodCall, MethodChannel.Result result) { 142 | Open_im_sdk.getFriendApplicationUnhandledCount( 143 | new OnBaseListener(result, methodCall), 144 | value(methodCall, "operationID"), 145 | jsonValue(methodCall, "req") 146 | ); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "2.13.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" 17 | url: "https://pub.dev" 18 | source: hosted 19 | version: "2.1.2" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 25 | url: "https://pub.dev" 26 | source: hosted 27 | version: "1.4.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b 33 | url: "https://pub.dev" 34 | source: hosted 35 | version: "1.1.2" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" 41 | url: "https://pub.dev" 42 | source: hosted 43 | version: "1.19.1" 44 | fake_async: 45 | dependency: transitive 46 | description: 47 | name: fake_async 48 | sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" 49 | url: "https://pub.dev" 50 | source: hosted 51 | version: "1.3.3" 52 | flutter: 53 | dependency: "direct main" 54 | description: flutter 55 | source: sdk 56 | version: "0.0.0" 57 | flutter_test: 58 | dependency: "direct dev" 59 | description: flutter 60 | source: sdk 61 | version: "0.0.0" 62 | leak_tracker: 63 | dependency: transitive 64 | description: 65 | name: leak_tracker 66 | sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" 67 | url: "https://pub.dev" 68 | source: hosted 69 | version: "10.0.9" 70 | leak_tracker_flutter_testing: 71 | dependency: transitive 72 | description: 73 | name: leak_tracker_flutter_testing 74 | sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 75 | url: "https://pub.dev" 76 | source: hosted 77 | version: "3.0.9" 78 | leak_tracker_testing: 79 | dependency: transitive 80 | description: 81 | name: leak_tracker_testing 82 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" 83 | url: "https://pub.dev" 84 | source: hosted 85 | version: "3.0.1" 86 | matcher: 87 | dependency: transitive 88 | description: 89 | name: matcher 90 | sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 91 | url: "https://pub.dev" 92 | source: hosted 93 | version: "0.12.17" 94 | material_color_utilities: 95 | dependency: transitive 96 | description: 97 | name: material_color_utilities 98 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec 99 | url: "https://pub.dev" 100 | source: hosted 101 | version: "0.11.1" 102 | meta: 103 | dependency: transitive 104 | description: 105 | name: meta 106 | sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c 107 | url: "https://pub.dev" 108 | source: hosted 109 | version: "1.16.0" 110 | path: 111 | dependency: transitive 112 | description: 113 | name: path 114 | sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" 115 | url: "https://pub.dev" 116 | source: hosted 117 | version: "1.9.1" 118 | sky_engine: 119 | dependency: transitive 120 | description: flutter 121 | source: sdk 122 | version: "0.0.0" 123 | source_span: 124 | dependency: transitive 125 | description: 126 | name: source_span 127 | sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" 128 | url: "https://pub.dev" 129 | source: hosted 130 | version: "1.10.1" 131 | stack_trace: 132 | dependency: transitive 133 | description: 134 | name: stack_trace 135 | sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" 136 | url: "https://pub.dev" 137 | source: hosted 138 | version: "1.12.1" 139 | stream_channel: 140 | dependency: transitive 141 | description: 142 | name: stream_channel 143 | sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" 144 | url: "https://pub.dev" 145 | source: hosted 146 | version: "2.1.4" 147 | string_scanner: 148 | dependency: transitive 149 | description: 150 | name: string_scanner 151 | sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" 152 | url: "https://pub.dev" 153 | source: hosted 154 | version: "1.4.1" 155 | term_glyph: 156 | dependency: transitive 157 | description: 158 | name: term_glyph 159 | sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" 160 | url: "https://pub.dev" 161 | source: hosted 162 | version: "1.2.2" 163 | test_api: 164 | dependency: transitive 165 | description: 166 | name: test_api 167 | sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd 168 | url: "https://pub.dev" 169 | source: hosted 170 | version: "0.7.4" 171 | vector_math: 172 | dependency: transitive 173 | description: 174 | name: vector_math 175 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 176 | url: "https://pub.dev" 177 | source: hosted 178 | version: "2.1.4" 179 | vm_service: 180 | dependency: transitive 181 | description: 182 | name: vm_service 183 | sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 184 | url: "https://pub.dev" 185 | source: hosted 186 | version: "15.0.0" 187 | sdks: 188 | dart: ">=3.7.0-0 <4.0.0" 189 | flutter: ">=3.18.0-18.0.pre.54" 190 | -------------------------------------------------------------------------------- /android/src/main/java/io/openim/flutter_openim_sdk/manager/ConversationManager.java: -------------------------------------------------------------------------------- 1 | package io.openim.flutter_openim_sdk.manager; 2 | 3 | import io.flutter.plugin.common.MethodCall; 4 | import io.flutter.plugin.common.MethodChannel; 5 | import io.openim.flutter_openim_sdk.listener.OnBaseListener; 6 | import io.openim.flutter_openim_sdk.listener.OnConversationListener; 7 | import io.openim.flutter_openim_sdk.util.CommonUtil; 8 | import open_im_sdk.Open_im_sdk; 9 | 10 | public class ConversationManager extends BaseManager { 11 | 12 | public void setConversationListener(MethodCall methodCall, MethodChannel.Result result) { 13 | Open_im_sdk.setConversationListener(new OnConversationListener()); 14 | 15 | result.success(null); 16 | } 17 | 18 | 19 | public void getAllConversationList(MethodCall methodCall, MethodChannel.Result result) { 20 | Open_im_sdk.getAllConversationList( 21 | new OnBaseListener(result, methodCall), 22 | value(methodCall, "operationID") 23 | ); 24 | } 25 | 26 | public void getConversationListSplit(MethodCall methodCall, MethodChannel.Result result) { 27 | Open_im_sdk.getConversationListSplit( 28 | new OnBaseListener(result, methodCall), 29 | value(methodCall, "operationID"), 30 | int2long(methodCall, "offset"), 31 | int2long(methodCall, "count") 32 | ); 33 | } 34 | 35 | public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) { 36 | Open_im_sdk.getOneConversation( 37 | new OnBaseListener(result, methodCall), 38 | value(methodCall, "operationID"), 39 | value(methodCall, "sessionType"), 40 | value(methodCall, "sourceID") 41 | ); 42 | } 43 | 44 | public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) { 45 | Open_im_sdk.getMultipleConversation( 46 | new OnBaseListener(result, methodCall), 47 | value(methodCall, "operationID"), 48 | jsonValue(methodCall, "conversationIDList") 49 | ); 50 | } 51 | 52 | 53 | public void setConversationDraft(MethodCall methodCall, MethodChannel.Result result) { 54 | Open_im_sdk.setConversationDraft( 55 | new OnBaseListener(result, methodCall), 56 | value(methodCall, "operationID"), 57 | value(methodCall, "conversationID"), 58 | value(methodCall, "draftText") 59 | ); 60 | } 61 | 62 | public void hideConversation(MethodCall methodCall, MethodChannel.Result result) { 63 | Open_im_sdk.hideConversation( 64 | new OnBaseListener(result, methodCall), 65 | value(methodCall, "operationID"), 66 | value(methodCall, "conversationID") 67 | ); 68 | } 69 | 70 | public void markConversationMessageAsRead(MethodCall methodCall, MethodChannel.Result result) { 71 | Open_im_sdk.markConversationMessageAsRead( 72 | new OnBaseListener(result, methodCall), 73 | value(methodCall, "operationID"), 74 | value(methodCall, "conversationID") 75 | ); 76 | } 77 | 78 | public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) { 79 | Open_im_sdk.getTotalUnreadMsgCount( 80 | new OnBaseListener(result, methodCall), 81 | value(methodCall, "operationID") 82 | ); 83 | } 84 | 85 | public void getConversationIDBySessionType(MethodCall methodCall, MethodChannel.Result result) { 86 | CommonUtil.runMainThreadReturn(result, Open_im_sdk.getConversationIDBySessionType( 87 | value(methodCall, "operationID"), 88 | value(methodCall, "sourceID"), 89 | int2long(methodCall, "sessionType"))); 90 | } 91 | 92 | public void clearConversationAndDeleteAllMsg(MethodCall methodCall, MethodChannel.Result result) { 93 | Open_im_sdk.clearConversationAndDeleteAllMsg( 94 | new OnBaseListener(result, methodCall), 95 | value(methodCall, "operationID"), 96 | value(methodCall, "conversationID") 97 | ); 98 | } 99 | 100 | public void deleteConversationAndDeleteAllMsg(MethodCall methodCall, MethodChannel.Result result) { 101 | Open_im_sdk.deleteConversationAndDeleteAllMsg( 102 | new OnBaseListener(result, methodCall), 103 | value(methodCall, "operationID"), 104 | value(methodCall, "conversationID") 105 | ); 106 | } 107 | 108 | public void getAtAllTag(MethodCall methodCall, MethodChannel.Result result) { 109 | CommonUtil.runMainThreadReturn(result, Open_im_sdk.getAtAllTag(value(methodCall, "operationID"))); 110 | } 111 | 112 | public void hideAllConversations(MethodCall methodCall, MethodChannel.Result result) { 113 | Open_im_sdk.hideAllConversations( 114 | new OnBaseListener(result, methodCall), 115 | value(methodCall, "operationID") 116 | ); 117 | } 118 | 119 | public void searchConversation(MethodCall methodCall, MethodChannel.Result result) { 120 | Open_im_sdk.searchConversation( 121 | new OnBaseListener(result, methodCall), 122 | value(methodCall, "operationID"), 123 | value(methodCall, "name") 124 | ); 125 | } 126 | 127 | public void changeInputStates(MethodCall methodCall, MethodChannel.Result result) { 128 | Open_im_sdk.changeInputStates( 129 | new OnBaseListener(result, methodCall), 130 | value(methodCall, "operationID"), 131 | value(methodCall, "conversationID"), 132 | value(methodCall, "focus") 133 | ); 134 | } 135 | 136 | public void getInputStates(MethodCall methodCall, MethodChannel.Result result) { 137 | Open_im_sdk.getInputStates( 138 | new OnBaseListener(result, methodCall), 139 | value(methodCall, "operationID"), 140 | value(methodCall, "conversationID"), 141 | value(methodCall, "userID") 142 | ); 143 | } 144 | 145 | public void setConversation(MethodCall methodCall, MethodChannel.Result result) { 146 | Open_im_sdk.setConversation( 147 | new OnBaseListener(result, methodCall), 148 | value(methodCall, "operationID"), 149 | value(methodCall, "conversationID"), 150 | jsonValue(methodCall, "req") 151 | ); 152 | } 153 | 154 | 155 | public void searchConversations(MethodCall methodCall, MethodChannel.Result result) { 156 | Open_im_sdk.searchConversation( 157 | new OnBaseListener(result, methodCall), 158 | value(methodCall, "operationID"), 159 | value(methodCall, "name") 160 | ); 161 | } 162 | } 163 | --------------------------------------------------------------------------------