new version sdk
This commit is contained in:
@@ -1,10 +1,3 @@
|
||||
//
|
||||
// BaseCallback.swift
|
||||
// flutter_openim_sdk
|
||||
//
|
||||
// Created by willem on 2021/10/9.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import OpenIMCore
|
||||
|
||||
@@ -16,7 +9,7 @@ public class BaseCallback: NSObject, Open_im_sdk_callbackBaseProtocol {
|
||||
self.result = result
|
||||
}
|
||||
|
||||
public func onError(_ errCode: Int, errMsg: String?) {
|
||||
public func onError(_ errCode: Int32, errMsg: String?) {
|
||||
print("BaseResult: " + errMsg!)
|
||||
safeMainAsync { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) }
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public class CommonUtil {
|
||||
|
||||
public static func emitEvent(channel: FlutterMethodChannel, method: String, type: String, errCode: Int?, errMsg: String?, data: Any?){
|
||||
public static func emitEvent(channel: FlutterMethodChannel, method: String, type: String, errCode: Int32?, errMsg: String?, data: Any?){
|
||||
safeMainAsync {
|
||||
var res: [String: Any] = [:]
|
||||
res["type"] = type
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
//
|
||||
// JsonUtil.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by z1u24 on 2021/6/28.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public class JsonUtil {
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
//
|
||||
// BaseServiceManager.swift
|
||||
// flutter_openim_sdk
|
||||
//
|
||||
// Created by willem on 2021/10/9.
|
||||
//
|
||||
|
||||
import Flutter
|
||||
import OpenIMCore
|
||||
import UIKit
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
//
|
||||
// ConversationManager.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by z1u24 on 2021/6/29.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import OpenIMCore
|
||||
|
||||
@@ -12,7 +5,6 @@ public class ConversationManager: BaseServiceManager {
|
||||
|
||||
public override func registerHandlers() {
|
||||
super.registerHandlers()
|
||||
|
||||
self["setConversationListener"] = setConversationListener
|
||||
self["getAllConversationList"] = getAllConversationList
|
||||
self["getConversationListSplit"] = getConversationListSplit
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
//
|
||||
// FriendshipManager.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by z1u24 on 2021/6/29.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import OpenIMCore
|
||||
|
||||
@@ -81,11 +74,11 @@ public class FriendshipManager: BaseServiceManager {
|
||||
}
|
||||
|
||||
func acceptFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkAcceptFriendApplication(BaseCallback(result: result), methodCall[string: "operationID", methodCall.toJsonString())
|
||||
Open_im_sdkAcceptFriendApplication(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
|
||||
}
|
||||
|
||||
func refuseFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkRefuseFriendApplication(BaseCallback(result: result), methodCall[string: "operationID", methodCall.toJsonString())
|
||||
Open_im_sdkRefuseFriendApplication(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
|
||||
}
|
||||
|
||||
// func forceSyncFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
@@ -104,35 +97,35 @@ public class FriendshipManager: BaseServiceManager {
|
||||
// }
|
||||
}
|
||||
|
||||
public class FriendshipListener: NSObject, Open_im_sdk_callbackFriendshipListenerProtocol {
|
||||
public class FriendshipListener: NSObject, Open_im_sdk_callbackOnFriendshipListenerProtocol {
|
||||
private let channel:FlutterMethodChannel
|
||||
|
||||
init(channel:FlutterMethodChannel) {
|
||||
self.channel = channel
|
||||
}
|
||||
|
||||
public func onBlackAdded(_ userInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onBlacklistAdded", errCode: nil, errMsg: nil, data: userInfo)
|
||||
public func onBlackAdded(_ blackInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onBlacklistAdded", errCode: nil, errMsg: nil, data: blackInfo)
|
||||
}
|
||||
|
||||
public func onBlackDeleted(_ userInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onBlacklistDeleted", errCode: nil, errMsg: nil, data: userInfo)
|
||||
public func onBlackDeleted(_ blackInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onBlacklistDeleted", errCode: nil, errMsg: nil, data: blackInfo)
|
||||
}
|
||||
|
||||
public func onFriendApplicationAccepted(_ applyUserInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationAccepted", errCode: nil, errMsg: nil, data: applyUserInfo)
|
||||
public func onFriendApplicationAccepted(_ friendApplication: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationAccepted", errCode: nil, errMsg: nil, data: friendApplication)
|
||||
}
|
||||
|
||||
public func onFriendApplicationAdded(_ applyUserInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationAdded", errCode: nil, errMsg: nil, data: applyUserInfo)
|
||||
public func onFriendApplicationAdded(_ friendApplication: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationAdded", errCode: nil, errMsg: nil, data: friendApplication)
|
||||
}
|
||||
|
||||
public func onFriendApplicationDeleted(_ applyUserInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationDeleted", errCode: nil, errMsg: nil, data: applyUserInfo)
|
||||
public func onFriendApplicationDeleted(_ friendApplication: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationDeleted", errCode: nil, errMsg: nil, data: friendApplication)
|
||||
}
|
||||
|
||||
public func onFriendApplicationRejected(_ applyUserInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationRejected", errCode: nil, errMsg: nil, data: applyUserInfo)
|
||||
public func onFriendApplicationRejected(_ friendApplication: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationRejected", errCode: nil, errMsg: nil, data: friendApplication)
|
||||
}
|
||||
|
||||
public func onFriendInfoChanged(_ friendInfo: String?) {
|
||||
@@ -146,6 +139,5 @@ public class FriendshipListener: NSObject, Open_im_sdk_callbackFriendshipListene
|
||||
public func onFriendDeleted(_ friendInfo: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendDeleted", errCode: nil, errMsg: nil, data: friendInfo)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
//
|
||||
// GroupManager.swift
|
||||
// flutter_openim_sdk
|
||||
//
|
||||
// Created by z1u24 on 2021/7/5.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import OpenIMCore
|
||||
|
||||
@@ -155,7 +148,7 @@ public class GroupListener: NSObject, Open_im_sdk_callbackOnGroupListenerProtoco
|
||||
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupMemberAdded", errCode: nil, errMsg: nil, data: s)
|
||||
}
|
||||
|
||||
public func onGroupMemberDeleted(_ s: String?,member s1: String?) {
|
||||
public func onGroupMemberDeleted(_ s: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupMemberDeleted", errCode: nil, errMsg: nil, data: s)
|
||||
}
|
||||
|
||||
@@ -170,12 +163,4 @@ public class GroupListener: NSObject, Open_im_sdk_callbackOnGroupListenerProtoco
|
||||
public func onJoinedGroupDeleted(_ s: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onJoinedGroupDeleted", errCode: nil, errMsg: nil, data: s)
|
||||
}
|
||||
|
||||
public func onReceiveJoinGroupApplicationAdded(_ s: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onReceiveJoinGroupApplicationAdded", errCode: nil, errMsg: nil, data: s)
|
||||
}
|
||||
|
||||
public func onReceiveJoinGroupApplicationDeleted(_ s: String?) {
|
||||
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onReceiveJoinGroupApplicationDeleted", errCode: nil, errMsg: nil, data: s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
//
|
||||
// IMManager.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by z1u24 on 2021/6/28.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import OpenIMCore
|
||||
|
||||
@@ -12,7 +5,6 @@ public class IMMananger: BaseServiceManager {
|
||||
|
||||
public override func registerHandlers() {
|
||||
super.registerHandlers()
|
||||
|
||||
self["initSDK"] = initSDK
|
||||
self["login"] = login
|
||||
self["logout"] = logout
|
||||
@@ -75,10 +67,10 @@ public class ConnListener: NSObject, Open_im_sdk_callbackOnConnListenerProtocol
|
||||
self.channel = channel
|
||||
}
|
||||
|
||||
public func onConnectFailed(_ errCode: Int, errMsg: String?) {
|
||||
public func onConnectFailed(_ errCode: Int32, errMsg: String?) {
|
||||
CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onConnectFailed", errCode: errCode, errMsg: errMsg, data: nil)
|
||||
}
|
||||
|
||||
|
||||
public func onConnectSuccess() {
|
||||
CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onConnectSuccess", errCode: nil, errMsg: nil, data: nil)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
//
|
||||
// MessageManager.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by z1u24 on 2021/6/29.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import OpenIMCore
|
||||
|
||||
@@ -14,7 +7,6 @@ public class MessageManager: BaseServiceManager {
|
||||
|
||||
public override func registerHandlers() {
|
||||
super.registerHandlers()
|
||||
|
||||
self["setAdvancedMsgListener"] = setAdvancedMsgListener
|
||||
self["sendMessage"] = sendMessage
|
||||
self["getHistoryMessageList"] = getHistoryMessageList
|
||||
@@ -49,7 +41,7 @@ public class MessageManager: BaseServiceManager {
|
||||
func setAdvancedMsgListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
let key = methodCall[string: KEY_ID]
|
||||
let lis = AdvancedMsgListener(channel: channel, id: key)
|
||||
open_im_sdkSetAdvancedMsgListener(lis)
|
||||
Open_im_sdkSetAdvancedMsgListener(lis)
|
||||
callBack(result)
|
||||
}
|
||||
|
||||
@@ -191,22 +183,11 @@ public class MessageManager: BaseServiceManager {
|
||||
self.call = methodCall
|
||||
}
|
||||
|
||||
// func setResult(result: @escaping FlutterResult){
|
||||
// self.result = result
|
||||
// }
|
||||
//
|
||||
// func setCall(methodCall: FlutterMethodCall){
|
||||
// self.call = methodCall
|
||||
// }
|
||||
|
||||
public func onError(_ errCode: Int, errMsg: String?) {
|
||||
public func onError(_ errCode: Int32, errMsg: String?) {
|
||||
DispatchQueue.main.async { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) }
|
||||
}
|
||||
|
||||
public func onProgress(_ progress: Int) {
|
||||
// guard let call = call else {
|
||||
// return
|
||||
// }
|
||||
var values: [String: Any] = [:]
|
||||
let message = call[dict: "message"]
|
||||
values["clientMsgID"] = message["clientMsgID"]
|
||||
@@ -224,12 +205,9 @@ public class MessageManager: BaseServiceManager {
|
||||
private let channel: FlutterMethodChannel
|
||||
private let id: String
|
||||
|
||||
// private var values: [String: Any] = [:]
|
||||
|
||||
init(channel: FlutterMethodChannel, id: String) {
|
||||
self.channel = channel
|
||||
self.id = id
|
||||
// values["id"] = id
|
||||
}
|
||||
|
||||
public func onRecvC2CReadReceipt(_ msgReceiptList: String?) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import Foundation
|
||||
import OpenIMCore
|
||||
|
||||
@@ -6,6 +5,7 @@ public class UserManager: BaseServiceManager {
|
||||
|
||||
public override func registerHandlers() {
|
||||
super.registerHandlers()
|
||||
self["setUserListener"] = setUserListener
|
||||
self["getUsersInfo"] = getUsersInfo
|
||||
self["setSelfInfo"] = setSelfInfo
|
||||
self["getSelfUserInfo"] = getSelfUserInfo
|
||||
@@ -32,7 +32,7 @@ public class UserManager: BaseServiceManager {
|
||||
public class UserListener: NSObject, Open_im_sdk_callbackOnUserListenerProtocol {
|
||||
|
||||
private let channel:FlutterMethodChannel
|
||||
|
||||
|
||||
init(channel:FlutterMethodChannel) {
|
||||
self.channel = channel
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import Flutter
|
||||
import UIKit
|
||||
|
||||
public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin {
|
||||
|
||||
let imManager: IMMananger
|
||||
let conversationManager: ConversationManager
|
||||
let friendshipManager: FriendshipManager
|
||||
|
||||
Reference in New Issue
Block a user