add some method
This commit is contained in:
parent
f503ba50e3
commit
bb5918b860
27
ios/Classes/BaseCallback.swift
Normal file
27
ios/Classes/BaseCallback.swift
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// BaseCallback.swift
|
||||||
|
// flutter_openim_sdk
|
||||||
|
//
|
||||||
|
// Created by willem on 2021/10/9.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import OpenIMCore
|
||||||
|
|
||||||
|
public class BaseCallback: NSObject, Open_im_sdkBaseProtocol {
|
||||||
|
|
||||||
|
private let result:FlutterResult
|
||||||
|
|
||||||
|
init(result:@escaping FlutterResult) {
|
||||||
|
self.result = result
|
||||||
|
}
|
||||||
|
|
||||||
|
public func onError(_ errCode: Int, errMsg: String?) {
|
||||||
|
print("BaseResult: " + errMsg!)
|
||||||
|
safeMainAsync { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) }
|
||||||
|
}
|
||||||
|
|
||||||
|
public func onSuccess(_ data: String?) {
|
||||||
|
safeMainAsync { self.result(data) }
|
||||||
|
}
|
||||||
|
}
|
@ -4,24 +4,6 @@ import Foundation
|
|||||||
|
|
||||||
public class CommonUtil {
|
public class CommonUtil {
|
||||||
|
|
||||||
public static func getParamValue(methodCall:FlutterMethodCall, param: String)->Any? {
|
|
||||||
let argument = methodCall.arguments as! NSDictionary
|
|
||||||
let arg = argument.value(forKey: param)
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSDKJsonParam(methodCall: FlutterMethodCall, key: String) -> String{
|
|
||||||
let argument = methodCall.arguments as! NSDictionary
|
|
||||||
let arg = argument.value(forKey: key) as AnyObject
|
|
||||||
return JsonUtil.toString(object: arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSDKJsonParam(methodCall: FlutterMethodCall) -> String{
|
|
||||||
let argument = methodCall.arguments as AnyObject
|
|
||||||
let s = JsonUtil.toString(object: argument)
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
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: Int?, errMsg: String?, data: Any?){
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let res: NSMutableDictionary = NSMutableDictionary(capacity: 0)
|
let res: NSMutableDictionary = NSMutableDictionary(capacity: 0)
|
||||||
@ -39,297 +21,4 @@ public class CommonUtil {
|
|||||||
channel.invokeMethod(method, arguments: res)
|
channel.invokeMethod(method, arguments: res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func getUid(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_UID) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getJsonUid(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_UID) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getToken(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_TOKEN) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getUidList(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_USER_IDS) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getMessageText(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_TEXT) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getAtUserList(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_AT_USER_LIST) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getImagePath(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_IMAGE_PATH) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSoundPath(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_SOUND_PATH) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSoundDuration(methodCall: FlutterMethodCall)->Int64{
|
|
||||||
let result: Int64 = getParamValue(methodCall: methodCall, param: KEY_SOUND_DURATION) as! Int64
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getVideoPath(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_VIDEO_PATH) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getVideoType(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_VIDEO_TYPE) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getVideoDuration(methodCall: FlutterMethodCall)->Int64{
|
|
||||||
let result: Int64 = getParamValue(methodCall: methodCall, param: KEY_VIDEO_DURATION) as! Int64
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getVideoSnapshotPath(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_VIDEO_SNAPSHOT_PATH) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getFilePath(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_FILE_PATH) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getFileName(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_FILE_NAME) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getMergerMessageList(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_MERGER_MESSAGE_LIST) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getMergerMessageTitle(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_MERGER_MESSAGE_TITLE) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSummaryList(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_SUMMARY_LIST) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getForwardMessage(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_FORWARD_MESSAGE) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSendMessageContent(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_SEND_MESSAGE_CONTENT)
|
|
||||||
if result is NSDictionary && result != nil {
|
|
||||||
return JsonUtil.toString(object: result as? NSDictionary)
|
|
||||||
}
|
|
||||||
return result as! String
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSendMessageClientMsgID(methodCall: FlutterMethodCall)->String{
|
|
||||||
let r = getParamValue(methodCall: methodCall, param: KEY_SEND_MESSAGE_CONTENT) as! NSDictionary
|
|
||||||
let result = r.value(forKey: KEY_SEND_MESSAGE_CONTENT_CLIENT_ID)
|
|
||||||
return result as! String
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSendMessageReceiver(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_SEND_MESSAGE_RECEIVER) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSendMessageGroupId(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_SEND_MESSAGE_GROUP_ID) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSendMessageOnlineOnly(methodCall: FlutterMethodCall)->Bool{
|
|
||||||
let result: Int = getParamValue(methodCall: methodCall, param: KEY_SEND_MESSAGE_ONLINE_ONLY) as! Int
|
|
||||||
return (result != 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSingleMessageContent(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_SINGLE_MESSAGE_CONTENT) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSingleMessageUserid(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_SINGLE_MESSAGE_USERID) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getUserid(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_SINGLE_MESSAGE_USERID) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGroupMessageGroupid(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_GROUP_MESSAGE_GROUPID) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getSingleMessageSender(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_SINGLE_MESSAGE_SENDER) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getMessageIds(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_MESSAGE_IDS) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getTyping(methodCall: FlutterMethodCall)->String {
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: "typing") as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getConversationId(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_CONVERSATION_ID) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getConversationIds(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_CONVERSATION_IDS) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getConversationSourceId(methodCall: FlutterMethodCall)->String {
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_CONVERSATION_SOURCE_ID) as! String;
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getConversationSessionType(methodCall: FlutterMethodCall)->Int{
|
|
||||||
let result: Int = getParamValue(methodCall: methodCall, param: KEY_CONVERSATION_SESSION_TYPE) as! Int
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getConversationDraft(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_CONVERSATION_DRAFT) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func isPinnedConversation(methodCall: FlutterMethodCall)->Bool{
|
|
||||||
let result: Int = getParamValue(methodCall: methodCall, param: KEY_SINGLE_MESSAGE_USERID) as! Int
|
|
||||||
return (result != 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGid(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_GROUP_ID) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGidList(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_GROUP_IDS) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGroupOpReason(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result: String = getParamValue(methodCall: methodCall, param: KEY_GROUP_OP_REASON) as! String
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGroupListFilter(methodCall: FlutterMethodCall)->Int32{
|
|
||||||
let result: Int32 = getParamValue(methodCall: methodCall, param: KEY_GROUP_LIST_FILTER) as! Int32
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGroupListNext(methodCall: FlutterMethodCall)->Int32{
|
|
||||||
let result: Int32 = getParamValue(methodCall: methodCall, param: KEY_GROUP_LIST_NEXT) as! Int32
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGroupInfo(methodCall: FlutterMethodCall)->String{
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_GROUP_INFO) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGroupMemberRoleList(methodCall: FlutterMethodCall)->String {
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_GROUP_MEMBER_ROLE_LIST) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func getGroupApplicationInfo(methodCall: FlutterMethodCall)->String {
|
|
||||||
let result = getParamValue(methodCall: methodCall, param: KEY_GROUP_APPLICATION_INFO) as AnyObject
|
|
||||||
let r = JsonUtil.toString(object: result)
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
//login
|
|
||||||
private static let KEY_UID: String = "uid";
|
|
||||||
private static let KEY_TOKEN: String = "token";
|
|
||||||
//create message body
|
|
||||||
private static let KEY_TEXT: String = "text";
|
|
||||||
private static let KEY_AT_USER_LIST: String = "atUserList";
|
|
||||||
private static let KEY_IMAGE_PATH: String = "imagePath";
|
|
||||||
private static let KEY_SOUND_PATH: String = "soundPath";
|
|
||||||
private static let KEY_SOUND_DURATION: String = "duration";
|
|
||||||
private static let KEY_VIDEO_PATH: String = "videoPath";
|
|
||||||
private static let KEY_VIDEO_TYPE: String = "videoType";
|
|
||||||
private static let KEY_VIDEO_DURATION: String = "duration";
|
|
||||||
private static let KEY_VIDEO_SNAPSHOT_PATH: String = "snapshotPath";
|
|
||||||
private static let KEY_FILE_PATH: String = "filePath";
|
|
||||||
private static let KEY_FILE_NAME: String = "fileName";
|
|
||||||
private static let KEY_MERGER_MESSAGE_LIST: String = "messageList";
|
|
||||||
private static let KEY_MERGER_MESSAGE_TITLE: String = "title";
|
|
||||||
private static let KEY_SUMMARY_LIST: String = "summaryList";
|
|
||||||
private static let KEY_FORWARD_MESSAGE: String = "message";
|
|
||||||
//send message
|
|
||||||
private static let KEY_SEND_MESSAGE_CONTENT: String = "message";
|
|
||||||
private static let KEY_SEND_MESSAGE_CONTENT_CLIENT_ID: String = "clientMsgID";
|
|
||||||
private static let KEY_SEND_MESSAGE_RECEIVER: String = "receiver";
|
|
||||||
private static let KEY_SEND_MESSAGE_GROUP_ID: String = "groupID";
|
|
||||||
private static let KEY_SEND_MESSAGE_ONLINE_ONLY: String = "onlineUserOnly";
|
|
||||||
//single chat
|
|
||||||
private static let KEY_SINGLE_MESSAGE_CONTENT: String = "message";
|
|
||||||
private static let KEY_SINGLE_MESSAGE_USERID: String = "userID";
|
|
||||||
private static let KEY_SINGLE_MESSAGE_SENDER: String = "sender";
|
|
||||||
//group chat
|
|
||||||
private static let KEY_GROUP_MESSAGE_GROUPID: String = "groupID";
|
|
||||||
// find message
|
|
||||||
private static let KEY_MESSAGE_IDS: String = "messageIDList";
|
|
||||||
// conversation
|
|
||||||
private static let KEY_CONVERSATION_ID: String = "conversationID";
|
|
||||||
private static let KEY_CONVERSATION_IDS: String = "conversationIDList";
|
|
||||||
private static let KEY_CONVERSATION_DRAFT: String = "draftText";
|
|
||||||
private static let KEY_CONVERSATION_PINNED: String = "isPinned";
|
|
||||||
private static let KEY_CONVERSATION_SOURCE_ID: String = "sourceID";
|
|
||||||
private static let KEY_CONVERSATION_SESSION_TYPE: String = "sessionType";
|
|
||||||
// user info
|
|
||||||
private static let KEY_USER_IDS: String = "uidList";
|
|
||||||
// group
|
|
||||||
private static let KEY_GROUP_ID: String = "gid";
|
|
||||||
private static let KEY_GROUP_IDS: String = "gidList";
|
|
||||||
private static let KEY_GROUP_OP_REASON: String = "reason";
|
|
||||||
private static let KEY_GROUP_LIST_FILTER: String = "filter";
|
|
||||||
private static let KEY_GROUP_LIST_NEXT: String = "next";
|
|
||||||
private static let KEY_GROUP_INFO: String = "gInfo";
|
|
||||||
private static let KEY_GROUP_MEMBER_ROLE_LIST: String = "memberList";
|
|
||||||
private static let KEY_GROUP_APPLICATION_INFO: String = "application";
|
|
||||||
}
|
}
|
||||||
|
@ -23,5 +23,4 @@ public class JsonUtil {
|
|||||||
let jsonStr = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
|
let jsonStr = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
|
||||||
return jsonStr! as String
|
return jsonStr! as String
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
50
ios/Classes/Module/BaseServiceManager.swift
Normal file
50
ios/Classes/Module/BaseServiceManager.swift
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// BaseServiceManager.swift
|
||||||
|
// flutter_openim_sdk
|
||||||
|
//
|
||||||
|
// Created by willem on 2021/10/9.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Flutter
|
||||||
|
import OpenIMCore
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
public typealias ImHandler = (_ methodCall: FlutterMethodCall, _ result: @escaping FlutterResult) -> Void
|
||||||
|
|
||||||
|
open class BaseServiceManager {
|
||||||
|
public let channel: FlutterMethodChannel
|
||||||
|
private var methodHandlers: [String: ImHandler] = [:]
|
||||||
|
|
||||||
|
public init(channel: FlutterMethodChannel) {
|
||||||
|
self.channel = channel
|
||||||
|
self.registerHandlers()
|
||||||
|
}
|
||||||
|
|
||||||
|
public func handleMethod(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
|
let method: String = call.method
|
||||||
|
guard let handler = methodHandlers[method] else {
|
||||||
|
print("Handle MethodName Error: \(typeName(self))'s method: [\(method)] not found")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
handler(call, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
public subscript(_ key: String) -> ImHandler? {
|
||||||
|
get {
|
||||||
|
methodHandlers[key]
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
methodHandlers[key] = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public func registerHandlers() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public func callBack(_ result: @escaping FlutterResult, _ content: Any? = nil) {
|
||||||
|
safeMainAsync {
|
||||||
|
result(content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,56 +8,68 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import OpenIMCore
|
import OpenIMCore
|
||||||
|
|
||||||
public class ConversationManager:NSObject{
|
public class ConversationManager: BaseServiceManager {
|
||||||
private let channel:FlutterMethodChannel
|
|
||||||
|
|
||||||
init(channel:FlutterMethodChannel) {
|
public override func registerHandlers() {
|
||||||
self.channel = channel
|
super.registerHandlers()
|
||||||
|
|
||||||
|
self["setConversationListener"] = setConversationListener
|
||||||
|
self["getAllConversationList"] = getAllConversationList
|
||||||
|
self["getOneConversation"] = getOneConversation
|
||||||
|
self["getMultipleConversation"] = getMultipleConversation
|
||||||
|
self["deleteConversation"] = deleteConversation
|
||||||
|
self["setConversationDraft"] = setConversationDraft
|
||||||
|
self["pinConversation"] = pinConversation
|
||||||
|
self["markSingleMessageHasRead"] = markSingleMessageHasRead
|
||||||
|
self["markGroupMessageHasRead"] = markGroupMessageHasRead
|
||||||
|
self["getTotalUnreadMsgCount"] = getTotalUnreadMsgCount
|
||||||
|
self["getConversationIDBySessionType"] = getConversationIDBySessionType
|
||||||
}
|
}
|
||||||
|
|
||||||
func setConversationListener(methodCall: FlutterMethodCall, result: FlutterResult){
|
func setConversationListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkSetConversationListener(ConversationListener(channel: channel))
|
Open_im_sdkSetConversationListener(ConversationListener(channel: channel))
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAllConversationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getAllConversationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetAllConversationList(BaseImpl(result: result))
|
Open_im_sdkGetAllConversationList(BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getOneConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getOneConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetOneConversation(CommonUtil.getConversationSourceId(methodCall: methodCall), CommonUtil.getConversationSessionType(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkGetOneConversation(methodCall[string: "sourceID"], methodCall[int: "sessionType"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMultipleConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getMultipleConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetMultipleConversation(CommonUtil.getConversationIds(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkGetMultipleConversation(methodCall[jsonString: "conversationIDList"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func deleteConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkDeleteConversation(CommonUtil.getConversationId(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkDeleteConversation(methodCall[string: "conversationID"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func setConversationDraft(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func setConversationDraft(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkSetConversationDraft(CommonUtil.getConversationId(methodCall: methodCall), CommonUtil.getConversationDraft(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkSetConversationDraft(methodCall[string: "conversationID"], methodCall[string: "draftText"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func pinConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func pinConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkPinConversation(CommonUtil.getConversationId(methodCall: methodCall), CommonUtil.isPinnedConversation(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkPinConversation(methodCall[string: "conversationID"], methodCall[bool: "isPinned"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func markSingleMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func markSingleMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkMarkSingleMessageHasRead(BaseImpl(result: result), CommonUtil.getSingleMessageUserid(methodCall: methodCall))
|
Open_im_sdkMarkSingleMessageHasRead(BaseCallback(result: result), methodCall[string: "userID"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func markGroupMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func markGroupMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkMarkGroupMessageHasRead(BaseImpl(result: result), CommonUtil.getGroupMessageGroupid(methodCall: methodCall))
|
Open_im_sdkMarkGroupMessageHasRead(BaseCallback(result: result), methodCall[string: "groupID"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTotalUnreadMsgCount(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getTotalUnreadMsgCount(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetTotalUnreadMsgCount(BaseImpl(result: result))
|
Open_im_sdkGetTotalUnreadMsgCount(BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConversationIDBySessionType(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getConversationIDBySessionType(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let conversationID = Open_im_sdkGetConversationIDBySessionType(CommonUtil.getConversationSourceId(methodCall: methodCall), CommonUtil.getConversationSessionType(methodCall: methodCall))
|
let conversationID = Open_im_sdkGetConversationIDBySessionType(methodCall[string: "sourceID"], methodCall[int: "sessionType"])
|
||||||
DispatchQueue.main.async { result(conversationID) }
|
callBack(result, conversationID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +105,6 @@ public class ConversationListener:NSObject,Open_im_sdkOnConversationListenerProt
|
|||||||
public func onTotalUnreadMessageCountChanged(_ totalUnreadCount: Int32) {
|
public func onTotalUnreadMessageCountChanged(_ totalUnreadCount: Int32) {
|
||||||
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onTotalUnreadMessageCountChanged", errCode: nil, errMsg: nil, data: totalUnreadCount)
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onTotalUnreadMessageCountChanged", errCode: nil, errMsg: nil, data: totalUnreadCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,75 +8,94 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import OpenIMCore
|
import OpenIMCore
|
||||||
|
|
||||||
public class FriendshipManager:NSObject{
|
public class FriendshipManager: BaseServiceManager {
|
||||||
private let channel:FlutterMethodChannel
|
|
||||||
|
|
||||||
init(channel:FlutterMethodChannel) {
|
public override func registerHandlers() {
|
||||||
self.channel = channel
|
super.registerHandlers()
|
||||||
|
self["setFriendListener"] = setFriendListener
|
||||||
|
self["getFriendsInfo"] = getFriendsInfo
|
||||||
|
self["addFriend"] = addFriend
|
||||||
|
self["getFriendApplicationList"] = getFriendApplicationList
|
||||||
|
self["getFriendList"] = getFriendList
|
||||||
|
self["setFriendInfo"] = setFriendInfo
|
||||||
|
self["addToBlackList"] = addToBlackList
|
||||||
|
self["getBlackList"] = getBlackList
|
||||||
|
self["deleteFromBlackList"] = deleteFromBlackList
|
||||||
|
self["checkFriend"] = checkFriend
|
||||||
|
self["deleteFromFriendList"] = deleteFromFriendList
|
||||||
|
self["acceptFriendApplication"] = acceptFriendApplication
|
||||||
|
self["refuseFriendApplication"] = refuseFriendApplication
|
||||||
|
self["forceSyncFriendApplication"] = forceSyncFriendApplication
|
||||||
|
self["forceSyncFriend"] = forceSyncFriend
|
||||||
|
self["forceSyncBlackList"] = forceSyncBlackList
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFriendListener(methodCall: FlutterMethodCall, result: FlutterResult){
|
func setFriendListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkSetFriendListener(FriendshipListener(channel: channel))
|
Open_im_sdkSetFriendListener(FriendshipListener(channel: channel))
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFriendsInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getFriendsInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetFriendsInfo(BaseImpl(result: result), CommonUtil.getUidList(methodCall: methodCall))
|
Open_im_sdkGetFriendsInfo(BaseCallback(result: result), methodCall[jsonString: "uidList"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func addFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func addFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkAddFriend(BaseImpl(result: result), CommonUtil.getSDKJsonParam(methodCall: methodCall))
|
Open_im_sdkAddFriend(BaseCallback(result: result), methodCall.toJsonString())
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFriendApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getFriendApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetFriendApplicationList(BaseImpl(result: result))
|
Open_im_sdkGetFriendApplicationList(BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFriendList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getFriendList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetFriendList(BaseImpl(result: result))
|
Open_im_sdkGetFriendList(BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFriendInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func setFriendInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkSetFriendInfo(CommonUtil.getSDKJsonParam(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkSetFriendInfo(methodCall.toJsonString(), BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func addToBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func addToBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkAddToBlackList(BaseImpl(result: result), CommonUtil.getJsonUid(methodCall: methodCall))
|
Open_im_sdkAddToBlackList(BaseCallback(result: result), methodCall[string: "uid"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetBlackList(BaseImpl(result: result))
|
Open_im_sdkGetBlackList(BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteFromBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func deleteFromBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkDeleteFromBlackList(BaseImpl(result: result), CommonUtil.getJsonUid(methodCall: methodCall))
|
Open_im_sdkDeleteFromBlackList(BaseCallback(result: result), methodCall[string: "uid"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func checkFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkCheckFriend(BaseImpl(result: result), CommonUtil.getUidList(methodCall: methodCall))
|
Open_im_sdkCheckFriend(BaseCallback(result: result), methodCall[jsonString: "uidList"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteFromFriendList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func deleteFromFriendList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkDeleteFromFriendList(CommonUtil.getJsonUid(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkDeleteFromFriendList(methodCall[string: "uid"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func acceptFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func acceptFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkAcceptFriendApplication(BaseImpl(result: result), CommonUtil.getJsonUid(methodCall: methodCall))
|
Open_im_sdkAcceptFriendApplication(BaseCallback(result: result), methodCall[string: "uid"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func refuseFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func refuseFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkRefuseFriendApplication(BaseImpl(result: result), CommonUtil.getJsonUid(methodCall: methodCall))
|
Open_im_sdkRefuseFriendApplication(BaseCallback(result: result), methodCall[string: "uid"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func forceSyncFriendApplication(methodCall: FlutterMethodCall, result: FlutterResult){
|
func forceSyncFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkForceSyncFriendApplication();
|
Open_im_sdkForceSyncFriendApplication();
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func forceSyncFriend(methodCall: FlutterMethodCall, result: FlutterResult){
|
func forceSyncFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkForceSyncFriend()
|
Open_im_sdkForceSyncFriend()
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func forceSyncBlackList(methodCall: FlutterMethodCall, result: FlutterResult){
|
func forceSyncBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkForceSyncBlackList()
|
Open_im_sdkForceSyncBlackList()
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,3 +143,4 @@ public class FriendshipListener:NSObject,Open_im_sdkOnFriendshipListenerProtocol
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,88 +8,114 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import OpenIMCore
|
import OpenIMCore
|
||||||
|
|
||||||
public class GroupManager:NSObject{
|
public class GroupManager: BaseServiceManager {
|
||||||
private let channel:FlutterMethodChannel
|
|
||||||
|
|
||||||
init(channel:FlutterMethodChannel) {
|
public override func registerHandlers() {
|
||||||
self.channel = channel
|
super.registerHandlers()
|
||||||
|
self["setGroupListener"] = setGroupListener
|
||||||
|
self["inviteUserToGroup"] = inviteUserToGroup
|
||||||
|
self["kickGroupMember"] = kickGroupMember
|
||||||
|
self["getGroupMembersInfo"] = getGroupMembersInfo
|
||||||
|
self["getGroupMemberList"] = getGroupMemberList
|
||||||
|
self["getJoinedGroupList"] = getJoinedGroupList
|
||||||
|
self["createGroup"] = createGroup
|
||||||
|
self["setGroupInfo"] = setGroupInfo
|
||||||
|
self["getGroupsInfo"] = getGroupsInfo
|
||||||
|
self["joinGroup"] = joinGroup
|
||||||
|
self["quitGroup"] = quitGroup
|
||||||
|
self["transferGroupOwner"] = transferGroupOwner
|
||||||
|
self["getGroupApplicationList"] = getGroupApplicationList
|
||||||
|
self["acceptGroupApplication"] = acceptGroupApplication
|
||||||
|
self["refuseGroupApplication"] = refuseGroupApplication
|
||||||
|
self["forceSyncApplyGroupRequest"] = forceSyncApplyGroupRequest
|
||||||
|
self["forceSyncGroupRequest"] = forceSyncGroupRequest
|
||||||
|
self["forceSyncJoinedGroup"] = forceSyncJoinedGroup
|
||||||
|
self["forceSyncJoinedGroupMember"] = forceSyncJoinedGroupMember
|
||||||
}
|
}
|
||||||
|
|
||||||
func setGroupListener(methodCall: FlutterMethodCall, result: FlutterResult){
|
func setGroupListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkSetGroupListener(GroupListener(channel: channel))
|
Open_im_sdkSetGroupListener(GroupListener(channel: channel))
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func inviteUserToGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func inviteUserToGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkInviteUserToGroup(CommonUtil.getGid(methodCall: methodCall), CommonUtil.getGroupOpReason(methodCall: methodCall), CommonUtil.getUidList(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkInviteUserToGroup(methodCall[string: "gid"], methodCall[string: "reason"],
|
||||||
|
methodCall[jsonString: "uidList"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func kickGroupMember(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func kickGroupMember(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkKickGroupMember(CommonUtil.getGid(methodCall: methodCall), CommonUtil.getGroupOpReason(methodCall: methodCall), CommonUtil.getUidList(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkKickGroupMember(methodCall[string: "gid"], methodCall[string: "reason"],
|
||||||
|
methodCall[jsonString: "uidList"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGroupMembersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getGroupMembersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetGroupMembersInfo(CommonUtil.getGid(methodCall: methodCall), CommonUtil.getUidList(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkGetGroupMembersInfo(methodCall[string: "gid"], methodCall[jsonString: "uidList"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGroupMemberList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getGroupMemberList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetGroupMemberList(CommonUtil.getGid(methodCall: methodCall), CommonUtil.getGroupListFilter(methodCall: methodCall), CommonUtil.getGroupListNext(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkGetGroupMemberList(methodCall[string: "gid"], methodCall[int32: "filter"],
|
||||||
|
methodCall[int32: "next"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getJoinedGroupList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getJoinedGroupList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetJoinedGroupList(BaseImpl(result: result))
|
Open_im_sdkGetJoinedGroupList(BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func createGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkCreateGroup(CommonUtil.getGroupInfo(methodCall: methodCall), CommonUtil.getGroupMemberRoleList(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkCreateGroup(methodCall[jsonString: "gInfo"], methodCall[jsonString: "memberList"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func setGroupInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func setGroupInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkSetGroupInfo(CommonUtil.getGroupInfo(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkSetGroupInfo(methodCall[jsonString: "gInfo"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGroupsInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getGroupsInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetGroupsInfo(CommonUtil.getGidList(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkGetGroupsInfo(methodCall[jsonString: "gidList"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func joinGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func joinGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkJoinGroup(CommonUtil.getGid(methodCall: methodCall), CommonUtil.getGroupOpReason(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkJoinGroup(methodCall[string: "gid"], methodCall[string: "reason"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func quitGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func quitGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkQuitGroup(CommonUtil.getGid(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkQuitGroup(methodCall[string: "gid"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func transferGroupOwner(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func transferGroupOwner(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkTransferGroupOwner(CommonUtil.getGid(methodCall: methodCall), CommonUtil.getUid(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkTransferGroupOwner(methodCall[string: "gid"], methodCall[string: "uid"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGroupApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getGroupApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetGroupApplicationList(BaseImpl(result: result))
|
Open_im_sdkGetGroupApplicationList(BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func acceptGroupApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func acceptGroupApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkAcceptGroupApplication(CommonUtil.getGroupApplicationInfo(methodCall: methodCall), CommonUtil.getGroupOpReason(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkAcceptGroupApplication(methodCall[jsonString: "application"], methodCall[string: "reason"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func refuseGroupApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func refuseGroupApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkRefuseGroupApplication(CommonUtil.getGroupApplicationInfo(methodCall: methodCall), CommonUtil.getGroupOpReason(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkRefuseGroupApplication(methodCall[jsonString: "application"], methodCall[string: "reason"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
// func forceSyncApplyGroupRequest(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func forceSyncApplyGroupRequest(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
// Open_im_sdkForceSyncApplyGroupRequest()
|
Open_im_sdkForceSyncApplyGroupRequest()
|
||||||
// }
|
callBack(result)
|
||||||
//
|
}
|
||||||
// func forceSyncGroupRequest(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
|
||||||
// Open_im_sdkForceSyncGroupRequest()
|
func forceSyncGroupRequest(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
// }
|
Open_im_sdkForceSyncGroupRequest()
|
||||||
//
|
callBack(result)
|
||||||
// func forceSyncJoinedGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
}
|
||||||
// Open_im_sdkForceSyncJoinedGroup()
|
|
||||||
// }
|
func forceSyncJoinedGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
//
|
Open_im_sdkForceSyncJoinedGroup()
|
||||||
// func forceSyncJoinedGroupMember(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
callBack(result)
|
||||||
// Open_im_sdkForceSyncJoinedGroupMember()
|
}
|
||||||
// }
|
|
||||||
|
func forceSyncJoinedGroupMember(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
|
Open_im_sdkForceSyncJoinedGroupMember()
|
||||||
|
callBack(result)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public class GroupListener:NSObject,Open_im_sdkOnGroupListenerProtocol {
|
public class GroupListener:NSObject,Open_im_sdkOnGroupListenerProtocol {
|
||||||
|
@ -8,48 +8,59 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import OpenIMCore
|
import OpenIMCore
|
||||||
|
|
||||||
public class IMMananger:NSObject{
|
public class IMMananger: BaseServiceManager {
|
||||||
|
|
||||||
private let channel:FlutterMethodChannel
|
public override func registerHandlers() {
|
||||||
|
super.registerHandlers()
|
||||||
|
|
||||||
init(channel:FlutterMethodChannel) {
|
self["initSDK"] = initSDK
|
||||||
self.channel = channel
|
self["login"] = login
|
||||||
|
self["logout"] = logout
|
||||||
|
self["getLoginStatus"] = getLoginStatus
|
||||||
|
self["getLoginUid"] = getLoginUid
|
||||||
|
self["getUsersInfo"] = getUsersInfo
|
||||||
|
self["setSelfInfo"] = setSelfInfo
|
||||||
|
self["forceSyncLoginUerInfo"] = forceSyncLoginUerInfo
|
||||||
|
self["forceReConn"] = forceReConn
|
||||||
}
|
}
|
||||||
|
|
||||||
func initSDK(methodCall: FlutterMethodCall, result: FlutterResult){
|
func initSDK(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkInitSDK(CommonUtil.getSDKJsonParam(methodCall: methodCall), SDKListener(channel: self.channel))
|
Open_im_sdkInitSDK(methodCall.toJsonString(), SDKListener(channel: self.channel))
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func login(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func login(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
Open_im_sdkLogin(CommonUtil.getUid(methodCall: methodCall), CommonUtil.getToken(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkLogin(methodCall[string: "uid"], methodCall[string: "token"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func logout(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func logout(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
Open_im_sdkLogout(BaseImpl(result: result))
|
Open_im_sdkLogout(BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLoginStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func getLoginStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
DispatchQueue.main.async { result(Open_im_sdkGetLoginStatus()) }
|
callBack(result, Open_im_sdkGetLoginStatus())
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLoginUid(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func getLoginUid(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
DispatchQueue.main.async { result(Open_im_sdkGetLoginUser()) }
|
callBack(result, Open_im_sdkGetLoginUser())
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUsersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func getUsersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
Open_im_sdkGetUsersInfo(CommonUtil.getUidList(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkGetUsersInfo(methodCall[jsonString: "uidList"], BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSelfInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func setSelfInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
Open_im_sdkSetSelfInfo(CommonUtil.getSDKJsonParam(methodCall: methodCall), BaseImpl(result: result))
|
Open_im_sdkSetSelfInfo(methodCall.toJsonString(), BaseCallback(result: result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func forceSyncLoginUerInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func forceSyncLoginUerInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
Open_im_sdkForceSyncLoginUerInfo()
|
Open_im_sdkForceSyncLoginUerInfo()
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func forceReConn(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func forceReConn(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
Open_im_sdkForceReConn()
|
Open_im_sdkForceReConn()
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,22 +95,3 @@ public class SDKListener:NSObject,Open_im_sdkIMSDKListenerProtocol {
|
|||||||
CommonUtil.emitEvent(channel: self.channel, method: "initSDKListener", type: "onUserTokenExpired", errCode: nil, errMsg: nil, data: nil);
|
CommonUtil.emitEvent(channel: self.channel, method: "initSDKListener", type: "onUserTokenExpired", errCode: nil, errMsg: nil, data: nil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BaseImpl:NSObject,Open_im_sdkBaseProtocol {
|
|
||||||
|
|
||||||
private let result:FlutterResult
|
|
||||||
|
|
||||||
init(result:@escaping FlutterResult) {
|
|
||||||
self.result = result
|
|
||||||
}
|
|
||||||
|
|
||||||
public func onError(_ errCode: Int, errMsg: String?) {
|
|
||||||
print("BaseImpl: " + errMsg!)
|
|
||||||
DispatchQueue.main.async { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
public func onSuccess(_ data: String?) {
|
|
||||||
DispatchQueue.main.async { self.result(data) }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -8,17 +8,43 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import OpenIMCore
|
import OpenIMCore
|
||||||
|
|
||||||
public class MessageManager:NSObject{
|
public class MessageManager: BaseServiceManager {
|
||||||
private let KEY_ID: String = "id"
|
private let KEY_ID: String = "id"
|
||||||
private let channel:FlutterMethodChannel
|
|
||||||
private let listeners: NSMutableDictionary = NSMutableDictionary(capacity: 0)
|
private let listeners: NSMutableDictionary = NSMutableDictionary(capacity: 0)
|
||||||
|
|
||||||
init(channel:FlutterMethodChannel) {
|
public override func registerHandlers() {
|
||||||
self.channel = channel
|
super.registerHandlers()
|
||||||
|
|
||||||
|
self["addAdvancedMsgListener"] = addAdvancedMsgListener
|
||||||
|
self["removeAdvancedMsgListener"] = removeAdvancedMsgListener
|
||||||
|
self["sendMessage"] = sendMessage
|
||||||
|
self["getHistoryMessageList"] = getHistoryMessageList
|
||||||
|
self["revokeMessage"] = revokeMessage
|
||||||
|
self["deleteMessageFromLocalStorage"] = deleteMessageFromLocalStorage
|
||||||
|
self["deleteMessages"] = deleteMessages
|
||||||
|
self["insertSingleMessageToLocalStorage"] = insertSingleMessageToLocalStorage
|
||||||
|
self["findMessages"] = findMessages
|
||||||
|
self["markC2CMessageAsRead"] = markC2CMessageAsRead
|
||||||
|
self["typingStatusUpdate"] = typingStatusUpdate
|
||||||
|
self["createTextMessage"] = createTextMessage
|
||||||
|
self["createTextAtMessage"] = createTextAtMessage
|
||||||
|
self["createImageMessage"] = createImageMessage
|
||||||
|
self["createImageMessageFromFullPath"] = createImageMessageFromFullPath
|
||||||
|
self["createSoundMessage"] = createSoundMessage
|
||||||
|
self["createSoundMessageFromFullPath"] = createSoundMessageFromFullPath
|
||||||
|
self["createVideoMessage"] = createVideoMessage
|
||||||
|
self["createVideoMessageFromFullPath"] = createVideoMessageFromFullPath
|
||||||
|
self["createFileMessage"] = createFileMessage
|
||||||
|
self["createMergerMessage"] = createMergerMessage
|
||||||
|
self["createForwardMessage"] = createForwardMessage
|
||||||
|
self["createLocationMessage"] = createLocationMessage
|
||||||
|
self["createCustomMessage"] = createCustomMessage
|
||||||
|
self["createQuoteMessage"] = createQuoteMessage
|
||||||
|
self["createCardMessage"] = createCardMessage
|
||||||
|
self["forceSyncMsg"] = forceSyncMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
func addAdvancedMsgListener(methodCall: FlutterMethodCall, result: FlutterResult){
|
func addAdvancedMsgListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
|
|
||||||
let d = methodCall.arguments as! NSDictionary
|
let d = methodCall.arguments as! NSDictionary
|
||||||
let key = d.value(forKey: KEY_ID) as! String
|
let key = d.value(forKey: KEY_ID) as! String
|
||||||
if !listeners.allKeys.contains(where: {($0 as! String).compare(key) == .orderedSame}) {
|
if !listeners.allKeys.contains(where: {($0 as! String).compare(key) == .orderedSame}) {
|
||||||
@ -29,9 +55,10 @@ public class MessageManager:NSObject{
|
|||||||
Open_im_sdkAddAdvancedMsgListener(lis)
|
Open_im_sdkAddAdvancedMsgListener(lis)
|
||||||
print("=================add msg listener======\n\(lis)");
|
print("=================add msg listener======\n\(lis)");
|
||||||
}
|
}
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeAdvancedMsgListener(methodCall: FlutterMethodCall, result: FlutterResult){
|
func removeAdvancedMsgListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let k = methodCall.arguments as! NSDictionary
|
let k = methodCall.arguments as! NSDictionary
|
||||||
let s = k.value(forKey: KEY_ID) as! String
|
let s = k.value(forKey: KEY_ID) as! String
|
||||||
if listeners.allKeys.contains(where: {($0 as! String).compare(s) == .orderedSame}) {
|
if listeners.allKeys.contains(where: {($0 as! String).compare(s) == .orderedSame}) {
|
||||||
@ -39,6 +66,7 @@ public class MessageManager:NSObject{
|
|||||||
listeners.removeObject(forKey: s)
|
listeners.removeObject(forKey: s)
|
||||||
Open_im_sdkRemoveAdvancedMsgListener(lis)
|
Open_im_sdkRemoveAdvancedMsgListener(lis)
|
||||||
}
|
}
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func sendMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
@ -46,89 +74,118 @@ public class MessageManager:NSObject{
|
|||||||
sendMsgProgressListener.setCall(methodCall: methodCall)
|
sendMsgProgressListener.setCall(methodCall: methodCall)
|
||||||
sendMsgProgressListener.setResult(result: result)
|
sendMsgProgressListener.setResult(result: result)
|
||||||
print("===============sendMessage===============")
|
print("===============sendMessage===============")
|
||||||
Open_im_sdkSendMessage(sendMsgProgressListener, CommonUtil.getSendMessageContent(methodCall: methodCall), CommonUtil.getSendMessageReceiver(methodCall: methodCall), CommonUtil.getSendMessageGroupId(methodCall: methodCall), CommonUtil.getSendMessageOnlineOnly(methodCall: methodCall))
|
Open_im_sdkSendMessage(sendMsgProgressListener, methodCall[jsonString: "message"], methodCall[string: "receiver"],
|
||||||
|
methodCall[string: "groupID"], methodCall[bool: "onlineUserOnly"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHistoryMessageList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func getHistoryMessageList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkGetHistoryMessageList(BaseImpl(result: result), CommonUtil.getSDKJsonParam(methodCall: methodCall))
|
Open_im_sdkGetHistoryMessageList(BaseCallback(result: result), methodCall.toJsonString())
|
||||||
}
|
}
|
||||||
|
|
||||||
func revokeMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func revokeMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkRevokeMessage(BaseImpl(result: result), CommonUtil.getSDKJsonParam(methodCall: methodCall))
|
Open_im_sdkRevokeMessage(BaseCallback(result: result), methodCall.toJsonString())
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteMessageFromLocalStorage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func deleteMessageFromLocalStorage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkDeleteMessageFromLocalStorage(BaseImpl(result: result), CommonUtil.getSDKJsonParam(methodCall: methodCall))
|
Open_im_sdkDeleteMessageFromLocalStorage(BaseCallback(result: result), methodCall.toJsonString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deprecated
|
||||||
func deleteMessages(methodCall: FlutterMethodCall, result: FlutterResult){
|
func deleteMessages(methodCall: FlutterMethodCall, result: FlutterResult){
|
||||||
}
|
}
|
||||||
|
|
||||||
func insertSingleMessageToLocalStorage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func insertSingleMessageToLocalStorage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkInsertSingleMessageToLocalStorage(BaseImpl(result: result), CommonUtil.getSingleMessageContent(methodCall: methodCall), CommonUtil.getSingleMessageUserid(methodCall: methodCall), CommonUtil.getSingleMessageSender(methodCall: methodCall))
|
Open_im_sdkInsertSingleMessageToLocalStorage(BaseCallback(result: result), methodCall[jsonString: "message"],
|
||||||
|
methodCall[string: "userID"], methodCall[string: "sender"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func findMessages(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func findMessages(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkFindMessages(BaseImpl(result: result), CommonUtil.getMessageIds(methodCall: methodCall))
|
Open_im_sdkFindMessages(BaseCallback(result: result), methodCall[jsonString: "messageIDList"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func markC2CMessageAsRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func markC2CMessageAsRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkMarkC2CMessageAsRead(BaseImpl(result: result), CommonUtil.getUserid(methodCall: methodCall), CommonUtil.getMessageIds(methodCall: methodCall))
|
Open_im_sdkMarkC2CMessageAsRead(BaseCallback(result: result), methodCall[string: "userID"], methodCall[jsonString: "messageIDList"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func typingStatusUpdate(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func typingStatusUpdate(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let receiver = CommonUtil.getUserid(methodCall: methodCall)
|
Open_im_sdkTypingStatusUpdate(methodCall[string: "userID"], methodCall[string: "typing"])
|
||||||
let typing = CommonUtil.getTyping(methodCall: methodCall)
|
callBack(result)
|
||||||
Open_im_sdkTypingStatusUpdate(receiver, typing)
|
|
||||||
DispatchQueue.main.async { result(nil) }
|
|
||||||
}
|
|
||||||
|
|
||||||
func markGroupMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
|
||||||
Open_im_sdkMarkGroupMessageHasRead(BaseImpl(result: result), CommonUtil.getGroupMessageGroupid(methodCall: methodCall))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTextMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createTextMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let prama = Open_im_sdkCreateTextMessage(CommonUtil.getMessageText(methodCall: methodCall))
|
callBack(result, Open_im_sdkCreateTextMessage(methodCall[string: "text"]))
|
||||||
DispatchQueue.main.async { result(prama) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTextAtMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createTextAtMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let prama = Open_im_sdkCreateTextAtMessage(CommonUtil.getMessageText(methodCall: methodCall), CommonUtil.getAtUserList(methodCall: methodCall))
|
callBack(result, Open_im_sdkCreateTextAtMessage(methodCall[string: "text"], methodCall[jsonString: "atUserList"]))
|
||||||
DispatchQueue.main.async { result(prama) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createImageMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createImageMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let prama = Open_im_sdkCreateImageMessage(CommonUtil.getImagePath(methodCall: methodCall))
|
callBack(result, Open_im_sdkCreateImageMessage(methodCall[string: "imagePath"]))
|
||||||
DispatchQueue.main.async { result(prama) }
|
}
|
||||||
|
|
||||||
|
func createImageMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
|
callBack(result, Open_im_sdkCreateImageMessageFromFullPath(methodCall[string: "imagePath"]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func createSoundMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createSoundMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let prama = Open_im_sdkCreateSoundMessage(CommonUtil.getSoundPath(methodCall: methodCall),CommonUtil.getSoundDuration(methodCall: methodCall))
|
callBack(result, Open_im_sdkCreateSoundMessage(methodCall[string: "soundPath"], methodCall[int64: "duration"]))
|
||||||
DispatchQueue.main.async { result(prama) }
|
}
|
||||||
|
|
||||||
|
func createSoundMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
|
callBack(result, Open_im_sdkCreateSoundMessageFromFullPath(methodCall[string: "soundPath"], methodCall[int64: "duration"]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func createVideoMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createVideoMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let prama = Open_im_sdkCreateVideoMessage(CommonUtil.getVideoPath(methodCall: methodCall), CommonUtil.getVideoType(methodCall: methodCall), CommonUtil.getVideoDuration(methodCall: methodCall), CommonUtil.getVideoSnapshotPath(methodCall: methodCall))
|
let prama = Open_im_sdkCreateVideoMessage(methodCall[string: "videoPath"], methodCall[string: "videoType"],
|
||||||
DispatchQueue.main.async { result(prama) }
|
methodCall[int64: "duration"], methodCall[string: "snapshotPath"])
|
||||||
|
callBack(result, prama)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createVideoMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
|
let prama = Open_im_sdkCreateVideoMessageFromFullPath(methodCall[string: "videoPath"], methodCall[string: "videoType"],
|
||||||
|
methodCall[int64: "duration"], methodCall[string: "snapshotPath"])
|
||||||
|
callBack(result, prama)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createFileMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createFileMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let prama = Open_im_sdkCreateFileMessage(CommonUtil.getFilePath(methodCall: methodCall), CommonUtil.getFileName(methodCall: methodCall))
|
callBack(result, Open_im_sdkCreateFileMessage(methodCall[string: "filePath"], methodCall[string: "fileName"]))
|
||||||
DispatchQueue.main.async { result(prama) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createMergerMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createMergerMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let prama = Open_im_sdkCreateMergerMessage(CommonUtil.getMergerMessageList(methodCall: methodCall), CommonUtil.getMergerMessageTitle(methodCall: methodCall), CommonUtil.getSummaryList(methodCall: methodCall))
|
let prama = Open_im_sdkCreateMergerMessage(methodCall[jsonString: "messageList"], methodCall[string: "title"],
|
||||||
DispatchQueue.main.async { result(prama) }
|
methodCall[jsonString: "summaryList"])
|
||||||
|
callBack(result, prama)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createForwardMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func createForwardMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
let prama = Open_im_sdkCreateForwardMessage(CommonUtil.getForwardMessage(methodCall: methodCall))
|
callBack(result, Open_im_sdkCreateForwardMessage(methodCall[jsonString: "message"]))
|
||||||
DispatchQueue.main.async { result(prama) }
|
}
|
||||||
|
|
||||||
|
func createLocationMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
|
let prama = Open_im_sdkCreateLocationMessage(methodCall[string: "description"],
|
||||||
|
methodCall[double: "longitude"], methodCall[double: "latitude"])
|
||||||
|
callBack(result, prama)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createCustomMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
|
let prama = Open_im_sdkCreateCustomMessage(methodCall[string: "data"],
|
||||||
|
methodCall[string: "extension"], methodCall[string: "description"])
|
||||||
|
callBack(result, prama)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createQuoteMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
|
let prama = Open_im_sdkCreateQuoteMessage(methodCall[string: "quoteText"], methodCall[jsonString: "quoteMessage"])
|
||||||
|
callBack(result, prama)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createCardMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
|
callBack(result, Open_im_sdkCreateCardMessage(methodCall[jsonString: "cardMessage"]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func forceSyncMsg(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
func forceSyncMsg(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||||
Open_im_sdkForceSyncMsg()
|
Open_im_sdkForceSyncMsg()
|
||||||
|
callBack(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SendMsgProgressListener:NSObject, Open_im_sdkSendMsgCallBackProtocol {
|
public class SendMsgProgressListener:NSObject, Open_im_sdkSendMsgCallBackProtocol {
|
||||||
@ -156,8 +213,11 @@ public class MessageManager:NSObject{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func onProgress(_ progress: Int) {
|
public func onProgress(_ progress: Int) {
|
||||||
|
guard let call = call else {
|
||||||
|
return
|
||||||
|
}
|
||||||
print("=================onProgress============\nprogress:\(progress)");
|
print("=================onProgress============\nprogress:\(progress)");
|
||||||
values.setValue(CommonUtil.getSendMessageClientMsgID(methodCall: self.call!), forKey: "clientMsgID")
|
values.setValue(call[string: "clientMsgID"], forKey: "clientMsgID")
|
||||||
values.setValue(progress, forKey: "progress")
|
values.setValue(progress, forKey: "progress")
|
||||||
CommonUtil.emitEvent(channel: channel, method: "msgSendProgressListener", type: "onProgress", errCode: nil, errMsg: nil, data: values)
|
CommonUtil.emitEvent(channel: channel, method: "msgSendProgressListener", type: "onProgress", errCode: nil, errMsg: nil, data: values)
|
||||||
}
|
}
|
||||||
|
@ -24,219 +24,21 @@ public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
let managerName: String = CommonUtil.getParamValue(methodCall: call, param: "ManagerName") as! String
|
let managerName: String = call[string: "ManagerName"]
|
||||||
if managerName == "imManager" {
|
switch managerName {
|
||||||
handleIMManager(call: call, result: result)
|
case "imManager":
|
||||||
}else if managerName == "conversationManager"{
|
imManager.handleMethod(call: call, result: result)
|
||||||
handleConversationManager(call: call, result: result)
|
case "conversationManager":
|
||||||
}else if managerName == "friendshipManager"{
|
conversationManager.handleMethod(call: call, result: result)
|
||||||
handleFriendshipManager(call: call, result: result)
|
case "messageManager":
|
||||||
}else if managerName == "messageManager"{
|
messageManager.handleMethod(call: call, result: result)
|
||||||
handleMessageManager(call: call, result: result)
|
case "friendshipManager":
|
||||||
}else if managerName == "groupManager"{
|
friendshipManager.handleMethod(call: call, result: result)
|
||||||
handleGroupManager(call: call, result: result)
|
case "groupManager":
|
||||||
}else{
|
groupManager.handleMethod(call: call, result: result)
|
||||||
|
default:
|
||||||
print("Handle ManagerName Error: \(managerName) not found")
|
print("Handle ManagerName Error: \(managerName) not found")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleIMManager(call: FlutterMethodCall, result: @escaping FlutterResult){
|
|
||||||
let method: String = call.method
|
|
||||||
if method == "initSDK" {
|
|
||||||
imManager.initSDK(methodCall: call, result: result)
|
|
||||||
}else if method == "login" {
|
|
||||||
imManager.login(methodCall: call, result: result)
|
|
||||||
}else if method == "logout" {
|
|
||||||
imManager.logout(methodCall: call, result: result)
|
|
||||||
}else if method == "getLoginStatus" {
|
|
||||||
imManager.getLoginStatus(methodCall: call, result: result)
|
|
||||||
}else if method == "getLoginUid" {
|
|
||||||
imManager.getLoginUid(methodCall: call, result: result)
|
|
||||||
}else if method == "getUsersInfo" {
|
|
||||||
imManager.getUsersInfo(methodCall: call, result: result)
|
|
||||||
}else if method == "setSelfInfo" {
|
|
||||||
imManager.setSelfInfo(methodCall: call, result: result)
|
|
||||||
}else if method == "forceSyncLoginUerInfo" {
|
|
||||||
imManager.forceSyncLoginUerInfo(methodCall: call, result: result)
|
|
||||||
}else if method == "forceReConn" {
|
|
||||||
imManager.forceReConn(methodCall: call, result: result)
|
|
||||||
}else{
|
|
||||||
print("Handle MethodName Error: IMManager method: \(method) not found")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func handleConversationManager(call: FlutterMethodCall, result: @escaping FlutterResult){
|
|
||||||
let method: String = call.method
|
|
||||||
if method == "setConversationListener" {
|
|
||||||
conversationManager.setConversationListener(methodCall: call, result: result)
|
|
||||||
}else if method == "getAllConversationList" {
|
|
||||||
conversationManager.getAllConversationList(methodCall: call, result: result)
|
|
||||||
}else if method == "getOneConversation" {
|
|
||||||
conversationManager.getOneConversation(methodCall: call, result: result)
|
|
||||||
}else if method == "getMultipleConversation" {
|
|
||||||
conversationManager.getMultipleConversation(methodCall: call, result: result)
|
|
||||||
}else if method == "deleteConversation" {
|
|
||||||
conversationManager.deleteConversation(methodCall: call, result: result)
|
|
||||||
}else if method == "setConversationDraft" {
|
|
||||||
conversationManager.setConversationDraft(methodCall: call, result: result)
|
|
||||||
}else if method == "pinConversation" {
|
|
||||||
conversationManager.pinConversation(methodCall: call, result: result)
|
|
||||||
}else if method == "markSingleMessageHasRead" {
|
|
||||||
conversationManager.markSingleMessageHasRead(methodCall: call, result: result)
|
|
||||||
}else if method == "markGroupMessageHasRead" {
|
|
||||||
conversationManager.markGroupMessageHasRead(methodCall: call, result: result)
|
|
||||||
}else if method == "getTotalUnreadMsgCount" {
|
|
||||||
conversationManager.getTotalUnreadMsgCount(methodCall: call, result: result)
|
|
||||||
}else if method == "getConversationIDBySessionType" {
|
|
||||||
conversationManager.getConversationIDBySessionType(methodCall: call, result: result)
|
|
||||||
}else{
|
|
||||||
print("Handle MethodName Error: ConversationManager method: \(method) not found")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func handleFriendshipManager(call: FlutterMethodCall, result: @escaping FlutterResult){
|
|
||||||
let method: String = call.method
|
|
||||||
if method == "setFriendListener" {
|
|
||||||
friendshipManager.setFriendListener(methodCall: call, result: result)
|
|
||||||
}else if method == "getFriendsInfo" {
|
|
||||||
friendshipManager.getFriendsInfo(methodCall: call, result: result)
|
|
||||||
}else if method == "addFriend" {
|
|
||||||
friendshipManager.addFriend(methodCall: call, result: result)
|
|
||||||
}else if method == "getFriendApplicationList" {
|
|
||||||
friendshipManager.getFriendApplicationList(methodCall: call, result: result)
|
|
||||||
}else if method == "getFriendList" {
|
|
||||||
friendshipManager.getFriendList(methodCall: call, result: result)
|
|
||||||
}else if method == "setFriendInfo" {
|
|
||||||
friendshipManager.setFriendInfo(methodCall: call, result: result)
|
|
||||||
}else if method == "addToBlackList" {
|
|
||||||
friendshipManager.addToBlackList(methodCall: call, result: result)
|
|
||||||
}else if method == "getBlackList" {
|
|
||||||
friendshipManager.getBlackList(methodCall: call, result: result)
|
|
||||||
}else if method == "deleteFromBlackList" {
|
|
||||||
friendshipManager.deleteFromBlackList(methodCall: call, result: result)
|
|
||||||
}else if method == "checkFriend" {
|
|
||||||
friendshipManager.checkFriend(methodCall: call, result: result)
|
|
||||||
}else if method == "deleteFromFriendList" {
|
|
||||||
friendshipManager.deleteFromFriendList(methodCall: call, result: result)
|
|
||||||
}else if method == "acceptFriendApplication" {
|
|
||||||
friendshipManager.acceptFriendApplication(methodCall: call, result: result)
|
|
||||||
}else if method == "refuseFriendApplication" {
|
|
||||||
friendshipManager.refuseFriendApplication(methodCall: call, result: result)
|
|
||||||
}else if method == "forceSyncFriendApplication" {
|
|
||||||
friendshipManager.forceSyncFriendApplication(methodCall: call, result: result)
|
|
||||||
}else if method == "forceSyncFriend" {
|
|
||||||
friendshipManager.forceSyncFriend(methodCall: call, result: result)
|
|
||||||
}else if method == "forceSyncBlackList" {
|
|
||||||
friendshipManager.forceSyncBlackList(methodCall: call, result: result)
|
|
||||||
}else{
|
|
||||||
print("Handle MethodName Error: FriendshipManager method: \(method) not found")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func handleMessageManager(call: FlutterMethodCall, result: @escaping FlutterResult){
|
|
||||||
let method: String = call.method
|
|
||||||
if method == "addAdvancedMsgListener" {
|
|
||||||
messageManager.addAdvancedMsgListener(methodCall: call, result: result)
|
|
||||||
}else if method == "removeAdvancedMsgListener" {
|
|
||||||
messageManager.removeAdvancedMsgListener(methodCall: call, result: result)
|
|
||||||
}else if method == "sendMessage" {
|
|
||||||
messageManager.sendMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "getHistoryMessageList" {
|
|
||||||
messageManager.getHistoryMessageList(methodCall: call, result: result)
|
|
||||||
}else if method == "revokeMessage" {
|
|
||||||
messageManager.revokeMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "deleteMessageFromLocalStorage" {
|
|
||||||
messageManager.deleteMessageFromLocalStorage(methodCall: call, result: result)
|
|
||||||
}else if method == "deleteMessages" {
|
|
||||||
messageManager.deleteMessages(methodCall: call, result: result)
|
|
||||||
}else if method == "insertSingleMessageToLocalStorage" {
|
|
||||||
messageManager.insertSingleMessageToLocalStorage(methodCall: call, result: result)
|
|
||||||
}else if method == "findMessages" {
|
|
||||||
messageManager.findMessages(methodCall: call, result: result)
|
|
||||||
}else if method == "markC2CMessageAsRead" {
|
|
||||||
messageManager.markC2CMessageAsRead(methodCall: call, result: result)
|
|
||||||
}else if method == "typingStatusUpdate" {
|
|
||||||
messageManager.typingStatusUpdate(methodCall: call, result: result)
|
|
||||||
}else if method == "createTextMessage" {
|
|
||||||
messageManager.createTextMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "createTextAtMessage" {
|
|
||||||
messageManager.createTextAtMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "createImageMessage" {
|
|
||||||
messageManager.createImageMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "createImageMessageFromFullPath" {
|
|
||||||
// TODO:
|
|
||||||
}else if method == "createSoundMessage" {
|
|
||||||
messageManager.createSoundMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "createSoundMessageFromFullPath" {
|
|
||||||
// TODO:
|
|
||||||
}else if method == "createVideoMessage" {
|
|
||||||
messageManager.createVideoMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "createVideoMessageFromFullPath" {
|
|
||||||
// TODO:
|
|
||||||
}else if method == "createFileMessage" {
|
|
||||||
messageManager.createFileMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "createMergerMessage" {
|
|
||||||
messageManager.createMergerMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "createForwardMessage" {
|
|
||||||
messageManager.createForwardMessage(methodCall: call, result: result)
|
|
||||||
}else if method == "createLocationMessage" {
|
|
||||||
// TODO:
|
|
||||||
}else if method == "createCustomMessage" {
|
|
||||||
// TODO:
|
|
||||||
}else if method == "createQuoteMessage" {
|
|
||||||
// TODO:
|
|
||||||
}else if method == "createCardMessage" {
|
|
||||||
// TODO:
|
|
||||||
}else if method == "forceSyncMsg" {
|
|
||||||
// TODO:
|
|
||||||
}else{
|
|
||||||
print("Handle MethodName Error: MessageManager method: \(method) not found")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func handleGroupManager(call: FlutterMethodCall, result: @escaping FlutterResult){
|
|
||||||
let method: String = call.method
|
|
||||||
if method == "setGroupListener" {
|
|
||||||
groupManager.setGroupListener(methodCall: call, result: result)
|
|
||||||
}else if method == "inviteUserToGroup" {
|
|
||||||
groupManager.inviteUserToGroup(methodCall: call, result: result)
|
|
||||||
}else if method == "kickGroupMember" {
|
|
||||||
groupManager.kickGroupMember(methodCall: call, result: result)
|
|
||||||
}else if method == "getGroupMembersInfo" {
|
|
||||||
groupManager.getGroupMembersInfo(methodCall: call, result: result)
|
|
||||||
}else if method == "getGroupMemberList" {
|
|
||||||
groupManager.getGroupMemberList(methodCall: call, result: result)
|
|
||||||
}else if method == "getJoinedGroupList" {
|
|
||||||
groupManager.getJoinedGroupList(methodCall: call, result: result)
|
|
||||||
}else if method == "createGroup" {
|
|
||||||
groupManager.createGroup(methodCall: call, result: result)
|
|
||||||
}else if method == "setGroupInfo" {
|
|
||||||
groupManager.setGroupInfo(methodCall: call, result: result)
|
|
||||||
}else if method == "getGroupsInfo" {
|
|
||||||
groupManager.getGroupsInfo(methodCall: call, result: result)
|
|
||||||
}else if method == "joinGroup" {
|
|
||||||
groupManager.joinGroup(methodCall: call, result: result)
|
|
||||||
}else if method == "quitGroup" {
|
|
||||||
groupManager.quitGroup(methodCall: call, result: result)
|
|
||||||
}else if method == "transferGroupOwner" {
|
|
||||||
groupManager.transferGroupOwner(methodCall: call, result: result)
|
|
||||||
}else if method == "getGroupApplicationList" {
|
|
||||||
groupManager.getGroupApplicationList(methodCall: call, result: result)
|
|
||||||
}else if method == "acceptGroupApplication" {
|
|
||||||
groupManager.acceptGroupApplication(methodCall: call, result: result)
|
|
||||||
}else if method == "refuseGroupApplication" {
|
|
||||||
groupManager.refuseGroupApplication(methodCall: call, result: result)
|
|
||||||
// }else if method == "forceSyncApplyGroupRequest" {
|
|
||||||
// groupManager.forceSyncApplyGroupRequest(methodCall: call, result: result)
|
|
||||||
// }else if method == "forceSyncGroupRequest" {
|
|
||||||
// groupManager.forceSyncGroupRequest(methodCall: call, result: result)
|
|
||||||
// }else if method == "forceSyncJoinedGroup" {
|
|
||||||
// groupManager.forceSyncJoinedGroup(methodCall: call, result: result)
|
|
||||||
// }else if method == "forceSyncJoinedGroupMember" {
|
|
||||||
// groupManager.forceSyncJoinedGroupMember(methodCall: call, result: result)
|
|
||||||
}else{
|
|
||||||
print("Handle MethodName Error: MessageManager method: \(method) not found")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
23
ios/Classes/Util/Any+Extension.swift
Normal file
23
ios/Classes/Util/Any+Extension.swift
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// Any+Extension.swift
|
||||||
|
// flutter_openim_sdk
|
||||||
|
//
|
||||||
|
// Created by willem on 2021/10/9.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public func typeName(_ obj: Any) -> String {
|
||||||
|
if obj is AnyClass {
|
||||||
|
return "\(obj)"
|
||||||
|
}
|
||||||
|
return "\(type(of: obj))"
|
||||||
|
}
|
||||||
|
|
||||||
|
public func safeMainAsync(_ work: @escaping @convention(block) () -> Void) {
|
||||||
|
if Thread.isMainThread {
|
||||||
|
work()
|
||||||
|
} else {
|
||||||
|
DispatchQueue.main.async(execute: work)
|
||||||
|
}
|
||||||
|
}
|
109
ios/Classes/Util/FlutterMethodCall+Extension.swift
Normal file
109
ios/Classes/Util/FlutterMethodCall+Extension.swift
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
//
|
||||||
|
// FlutterMethodCall+Extension.swift
|
||||||
|
// flutter_openim_sdk
|
||||||
|
//
|
||||||
|
// Created by willem on 2021/10/9.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Flutter
|
||||||
|
|
||||||
|
public protocol Stringable {
|
||||||
|
var rawValue: String { get }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension String: Stringable {
|
||||||
|
public var rawValue: String { self }
|
||||||
|
}
|
||||||
|
|
||||||
|
public extension FlutterMethodCall {
|
||||||
|
subscript(_ key: Stringable) -> Any? {
|
||||||
|
guard let params = self.arguments as? [String: Any] else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return params[key.rawValue]
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(string key: Stringable) -> String {
|
||||||
|
return self[key] as? String ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(jsonString key: Stringable) -> String {
|
||||||
|
guard let params = self.arguments as? [String: Any] else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
let arg = params[key.rawValue] as AnyObject
|
||||||
|
return JsonUtil.toString(object: arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(int32 key: Stringable) -> Int32 {
|
||||||
|
guard let value = self[key] else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if let value = value as? Int32 {
|
||||||
|
return value
|
||||||
|
} else if let value = value as? String {
|
||||||
|
return Int32(value) ?? 0
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(int64 key: Stringable) -> Int64 {
|
||||||
|
guard let value = self[key] else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if let value = value as? Int64 {
|
||||||
|
return value
|
||||||
|
} else if let value = value as? String {
|
||||||
|
return Int64(value) ?? 0
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(int key: Stringable) -> Int {
|
||||||
|
guard let value = self[key] else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if let value = value as? Int {
|
||||||
|
return value
|
||||||
|
} else if let value = value as? String {
|
||||||
|
return Int(value) ?? 0
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(double key: Stringable) -> Double {
|
||||||
|
guard let value = self[key] else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if let value = value as? Double {
|
||||||
|
return value
|
||||||
|
} else if let value = value as? String {
|
||||||
|
return Double(value) ?? 0.0
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(bool key: Stringable, default default: Bool = false) -> Bool {
|
||||||
|
guard let value = self[key] else {
|
||||||
|
return `default`
|
||||||
|
}
|
||||||
|
if let value = value as? Bool {
|
||||||
|
return value
|
||||||
|
} else if let value = value as? Int {
|
||||||
|
return value != 0
|
||||||
|
} else if let value = value as? NSString {
|
||||||
|
return value.boolValue
|
||||||
|
}
|
||||||
|
return `default`
|
||||||
|
}
|
||||||
|
|
||||||
|
subscript(dict key: Stringable) -> [AnyHashable: Any] {
|
||||||
|
return self[key] as? [AnyHashable: Any] ?? [:]
|
||||||
|
}
|
||||||
|
|
||||||
|
func toJsonString() -> String {
|
||||||
|
let params = self.arguments as AnyObject
|
||||||
|
return JsonUtil.toString(object: params)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user