Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ Chat-Unity/chat_unity_quickstart/ProjectSettings/
Chat-Unity/chat_unity_quickstart/UserSettings/EditorUserSettings.asset
Chat-Unity/chat_unity_quickstart/UserSettings/
Chat-Unity/chat_unity_quickstart/Packages/
/Chat-iOS/AgoraChatAPIExample-Swift/AgoraChatAPIExample-Swift/Pods
/Chat-iOS/AgoraChatAPIExample/Pods
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
05F4366A28F1200600AC9A46 /* AgoraChatSendVideoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05F4366928F1200600AC9A46 /* AgoraChatSendVideoController.swift */; };
662FBDBA28615AEC0089A3CF /* AgoraChatImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 662FBDB928615AEC0089A3CF /* AgoraChatImageCell.swift */; };
66DEBE42286040AF00AB9465 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DEBE41286040AF00AB9465 /* AppDelegate.swift */; };
66DEBE46286040AF00AB9465 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DEBE45286040AF00AB9465 /* ViewController.swift */; };
Expand All @@ -17,11 +18,12 @@
66DEBE5A2860577600AB9465 /* AgoraChatSendTextViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DEBE592860577600AB9465 /* AgoraChatSendTextViewController.swift */; };
66DEBE5F28605AAA00AB9465 /* AgoraChatTextCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DEBE5E28605AAA00AB9465 /* AgoraChatTextCell.swift */; };
66DEBE6128605CF900AB9465 /* AgoraChatConversationsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DEBE6028605CF900AB9465 /* AgoraChatConversationsViewController.swift */; };
66DEBE63286070F800AB9465 /* AgoraChatSendImageVideoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DEBE62286070F800AB9465 /* AgoraChatSendImageVideoController.swift */; };
66DEBE63286070F800AB9465 /* AgoraChatSendImageController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DEBE62286070F800AB9465 /* AgoraChatSendImageController.swift */; };
F9F9666FA1F0D5957A12DB6B /* Pods_AgoraChatAPIExample_Swift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C4B62263AADB6A28ED3EC79 /* Pods_AgoraChatAPIExample_Swift.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
05F4366928F1200600AC9A46 /* AgoraChatSendVideoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraChatSendVideoController.swift; sourceTree = "<group>"; };
13D4326DAA8D17023CED02A4 /* Pods-AgoraChatAPIExample-Swift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AgoraChatAPIExample-Swift.release.xcconfig"; path = "Target Support Files/Pods-AgoraChatAPIExample-Swift/Pods-AgoraChatAPIExample-Swift.release.xcconfig"; sourceTree = "<group>"; };
662FBDB928615AEC0089A3CF /* AgoraChatImageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraChatImageCell.swift; sourceTree = "<group>"; };
66DEBE3E286040AF00AB9465 /* AgoraChatAPIExample-Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AgoraChatAPIExample-Swift.app"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -35,7 +37,7 @@
66DEBE592860577600AB9465 /* AgoraChatSendTextViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraChatSendTextViewController.swift; sourceTree = "<group>"; };
66DEBE5E28605AAA00AB9465 /* AgoraChatTextCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraChatTextCell.swift; sourceTree = "<group>"; };
66DEBE6028605CF900AB9465 /* AgoraChatConversationsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraChatConversationsViewController.swift; sourceTree = "<group>"; };
66DEBE62286070F800AB9465 /* AgoraChatSendImageVideoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraChatSendImageVideoController.swift; sourceTree = "<group>"; };
66DEBE62286070F800AB9465 /* AgoraChatSendImageController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgoraChatSendImageController.swift; sourceTree = "<group>"; };
9C4B62263AADB6A28ED3EC79 /* Pods_AgoraChatAPIExample_Swift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AgoraChatAPIExample_Swift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C73A60BA5101D95C00C51B3F /* Pods-AgoraChatAPIExample-Swift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AgoraChatAPIExample-Swift.debug.xcconfig"; path = "Target Support Files/Pods-AgoraChatAPIExample-Swift/Pods-AgoraChatAPIExample-Swift.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -90,7 +92,8 @@
66DEBE45286040AF00AB9465 /* ViewController.swift */,
66DEBE572860489600AB9465 /* AgoraChatLoginViewController.swift */,
66DEBE592860577600AB9465 /* AgoraChatSendTextViewController.swift */,
66DEBE62286070F800AB9465 /* AgoraChatSendImageVideoController.swift */,
66DEBE62286070F800AB9465 /* AgoraChatSendImageController.swift */,
05F4366928F1200600AC9A46 /* AgoraChatSendVideoController.swift */,
66DEBE6028605CF900AB9465 /* AgoraChatConversationsViewController.swift */,
);
path = Controllers;
Expand Down Expand Up @@ -228,10 +231,14 @@
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-AgoraChatAPIExample-Swift/Pods-AgoraChatAPIExample-Swift-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-AgoraChatAPIExample-Swift/Pods-AgoraChatAPIExample-Swift-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AgoraChatAPIExample-Swift/Pods-AgoraChatAPIExample-Swift-frameworks.sh\"\n";
Expand All @@ -248,8 +255,9 @@
66DEBE5F28605AAA00AB9465 /* AgoraChatTextCell.swift in Sources */,
66DEBE5A2860577600AB9465 /* AgoraChatSendTextViewController.swift in Sources */,
66DEBE42286040AF00AB9465 /* AppDelegate.swift in Sources */,
66DEBE63286070F800AB9465 /* AgoraChatSendImageVideoController.swift in Sources */,
66DEBE63286070F800AB9465 /* AgoraChatSendImageController.swift in Sources */,
662FBDBA28615AEC0089A3CF /* AgoraChatImageCell.swift in Sources */,
05F4366A28F1200600AC9A46 /* AgoraChatSendVideoController.swift in Sources */,
66DEBE562860436B00AB9465 /* AgoraChatRequest.swift in Sources */,
66DEBE582860489600AB9465 /* AgoraChatLoginViewController.swift in Sources */,
66DEBE6128605CF900AB9465 /* AgoraChatConversationsViewController.swift in Sources */,
Expand Down Expand Up @@ -392,9 +400,10 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 499WYUV8Q2;
DEVELOPMENT_TEAM = JC854K845H;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "AgoraChatAPIExample-Swift/Info.plist";
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "using send image";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
Expand All @@ -406,7 +415,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "luomobancheng-gmail.com.AgoraChatAPIExample-Swift";
PRODUCT_BUNDLE_IDENTIFIER = "com.AgoraChatAPIExample-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -422,9 +431,10 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 499WYUV8Q2;
DEVELOPMENT_TEAM = JC854K845H;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "AgoraChatAPIExample-Swift/Info.plist";
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "using send image";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
Expand All @@ -436,7 +446,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "luomobancheng-gmail.com.AgoraChatAPIExample-Swift";
PRODUCT_BUNDLE_IDENTIFIER = "com.AgoraChatAPIExample-Swift";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

private func agoraChatInitlize() {
let options = AgoraChatOptions(appkey: AgoraChatRequest.appKey)
let options = AgoraChatOptions(appId: AgoraChatRequest.appID)
options.enableConsoleLog = true
options.isAutoLogin = true
options.pushKitCertName = "com.easemob.enterprise.demo.ui.voip"
options.apnsCertName = "ChatDemoDevPush"

AgoraChatClient.shared().initializeSDK(with: options)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension AgoraChatImageCell {
guard let body = message.body as? AgoraChatImageMessageBody else { return }
if body.localPath.isEmpty,body.thumbnailLocalPath.isEmpty {
ProgressHUD.show("downloading image...")
AgoraChatClient.shared().chatManager.downloadMessageAttachment(message, progress: nil) { msg, error in
AgoraChatClient.shared().chatManager?.downloadMessageAttachment(message, progress: nil) { msg, error in
ProgressHUD.dismiss()
if error == nil {
self.picture.image = UIImage(contentsOfFile: body.thumbnailLocalPath.isEmpty ? body.localPath:body.thumbnailLocalPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class AgoraChatConversationsViewController: UIViewController,UITableViewDe

override func viewDidLoad() {
super.viewDidLoad()
guard let datas = AgoraChatClient.shared().chatManager.getAllConversations() else { return }
guard let datas = AgoraChatClient.shared().chatManager?.getAllConversations() else { return }
if self.title == "Join a group" {
self.conversations = datas.filter({ $0.type == .groupChat })
} else {
Expand All @@ -32,12 +32,12 @@ final class AgoraChatConversationsViewController: UIViewController,UITableViewDe
// Do any additional setup after loading the view.
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addChat))
self.view.addSubview(self.conversationList)
AgoraChatClient.shared().chatManager.add(self, delegateQueue: .main)
AgoraChatClient.shared().chatManager?.add(self, delegateQueue: .main)
}

deinit {
AgoraChatClient.shared().removeDelegate(self)
AgoraChatClient.shared().chatManager.remove(self)
AgoraChatClient.shared().chatManager?.remove(self)
}
}

Expand Down Expand Up @@ -71,7 +71,7 @@ extension AgoraChatConversationsViewController {
case "Send text message":
VC = AgoraChatSendTextViewController.init(to)
case "Send image message":
VC = AgoraChatSendImageVideoController.init(to)
VC = AgoraChatSendImageController.init(to)
default:
VC = AgoraChatSendTextViewController.init(to)
}
Expand Down Expand Up @@ -102,7 +102,7 @@ extension AgoraChatConversationsViewController {
return
}
if self.title == "Join a group" {
AgoraChatClient.shared().groupManager.joinPublicGroup(self.toChatId) { group, error in
AgoraChatClient.shared().groupManager?.joinPublicGroup(self.toChatId) { group, error in
if error == nil {
self.createConversation(.groupChat)
} else {
Expand All @@ -116,16 +116,17 @@ extension AgoraChatConversationsViewController {
}

private func createConversation(_ type: AgoraChatConversationType) {
let item: AgoraChatConversation = AgoraChatClient.shared().chatManager.getConversation(self.toChatId, type: type, createIfNotExist: true)!
let temp = self.conversations.filter { $0.conversationId == item.conversationId
}
if temp.count <= 0 {
self.conversations.append(item)
self.conversationList.reloadData()
if let item: AgoraChatConversation = AgoraChatClient.shared().chatManager?.getConversation(self.toChatId, type: type, createIfNotExist: true) {
let temp = self.conversations.filter { $0.conversationId == item.conversationId
}
if temp.count <= 0 {
self.conversations.append(item)
self.conversationList.reloadData()
}
let to = self.toChatId
let message = AgoraChatMessage(conversationID: to, from: AgoraChatClient.shared().currentUsername!, to: to, body: AgoraChatTextMessageBody(text: "Hello!"), ext: [:])
AgoraChatClient.shared().chatManager?.send(message, progress: nil)
}
let to = self.toChatId
let message = AgoraChatMessage(conversationID: to, from: AgoraChatClient.shared().currentUsername!, to: to, body: AgoraChatTextMessageBody(text: "Hello!"), ext: [:])
AgoraChatClient.shared().chatManager.send(message, progress: nil)
}

//MARK: - UITextFieldDelegate
Expand All @@ -136,11 +137,12 @@ extension AgoraChatConversationsViewController {
//MARK: - AgoraChatManagerDelegate
func messagesDidReceive(_ aMessages: [AgoraChatMessage]) {
for message in aMessages {
let item: AgoraChatConversation = AgoraChatClient.shared().chatManager.getConversation(message.conversationId, type: AgoraChatConversationType.init(rawValue: 0)!, createIfNotExist: true)!
let temp = self.conversations.filter { $0.conversationId == item.conversationId
}
if temp.count <= 0 {
self.conversations.append(item)
if let item: AgoraChatConversation = AgoraChatClient.shared().chatManager?.getConversation(message.conversationId, type: AgoraChatConversationType(rawValue: 0) ?? .chat, createIfNotExist: true) {
let temp = self.conversations.filter { $0.conversationId == item.conversationId
}
if temp.count <= 0 {
self.conversations.append(item)
}
}
}
DispatchQueue.main.async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit
import Photos
import ZSwiftBaseLib

final class AgoraChatSendImageVideoController: UIViewController,UITableViewDelegate,UITableViewDataSource,AgoraChatClientDelegate, AgoraChatManagerDelegate,UIImagePickerControllerDelegate, UINavigationControllerDelegate {
final class AgoraChatSendImageController: UIViewController,UITableViewDelegate,UITableViewDataSource,AgoraChatClientDelegate, AgoraChatManagerDelegate,UIImagePickerControllerDelegate, UINavigationControllerDelegate {

private var filePath = ""

Expand All @@ -34,7 +34,7 @@ final class AgoraChatSendImageVideoController: UIViewController,UITableViewDeleg

convenience init(_ conversationId: String) {
self.init()
self.conversation = AgoraChatClient.shared().chatManager.getConversationWithConvId(conversationId)
self.conversation = AgoraChatClient.shared().chatManager?.getConversationWithConvId(conversationId)
let messages = self.conversation?.loadMessagesStart(fromId: "", count: 50, searchDirection: AgoraChatMessageSearchDirection.init(rawValue: 0)!) ?? []
for message in messages {
if message.body.type == .image {
Expand All @@ -47,20 +47,20 @@ final class AgoraChatSendImageVideoController: UIViewController,UITableViewDeleg
super.viewDidLoad()
self.view.addSubViews([self.messagesList,self.sendImage])
AgoraChatClient.shared().add(self, delegateQueue: .main)
AgoraChatClient.shared().chatManager.add(self, delegateQueue: .main)
AgoraChatClient.shared().chatManager?.add(self, delegateQueue: .main)
// Do any additional setup after loading the view.
}

deinit {
AgoraChatClient.shared().removeDelegate(self)
AgoraChatClient.shared().chatManager.remove(self)
AgoraChatClient.shared().chatManager?.remove(self)
NotificationCenter.default.removeObserver(self)
}

}

//MARK: - Private method
extension AgoraChatSendImageVideoController {
extension AgoraChatSendImageController {

@objc private func sendImageAction() {
PHPhotoLibrary.requestAuthorization { status in
Expand Down Expand Up @@ -105,10 +105,10 @@ extension AgoraChatSendImageVideoController {
let to = self.conversation?.conversationId ?? ""
let message = AgoraChatMessage(conversationID: to, from: AgoraChatClient.shared().currentUsername!, to: to, body: body, ext: nil)
ProgressHUD.show("sending image...")
AgoraChatClient.shared().chatManager.send(message, progress: nil) { msg, error in
AgoraChatClient.shared().chatManager?.send(message, progress: nil) { msg, error in
ProgressHUD.dismiss()
if error == nil {
self.messages.append(msg!)
if error == nil,let message = msg {
self.messages.append(message)
self.messagesList.reloadData()
} else {
ProgressHUD.showError("\(error?.errorDescription ?? "")")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class AgoraChatSendTextViewController: UIViewController,UITableViewDelegat

convenience init(_ conversationId: String) {
self.init()
self.conversation = AgoraChatClient.shared().chatManager.getConversationWithConvId(conversationId)
self.conversation = AgoraChatClient.shared().chatManager?.getConversationWithConvId(conversationId)
let messages = self.conversation?.loadMessagesStart(fromId: "", count: 50, searchDirection: .up) ?? []
for message in messages {
if message.body.type == .text {
Expand All @@ -45,14 +45,14 @@ final class AgoraChatSendTextViewController: UIViewController,UITableViewDelegat
self.view.addSubViews([self.messagesList,self.messageField])
self.messageField.returnKeyType = .send
AgoraChatClient.shared().add(self, delegateQueue: .main)
AgoraChatClient.shared().chatManager.add(self, delegateQueue: .main)
AgoraChatClient.shared().chatManager?.add(self, delegateQueue: .main)
NotificationCenter.default.addObserver(self, selector: #selector(showKeyboard(notify:)), name: UIResponder.keyboardWillShowNotification, object: nil)
// Do any additional setup after loading the view.
}

deinit {
AgoraChatClient.shared().removeDelegate(self)
AgoraChatClient.shared().chatManager.remove(self)
AgoraChatClient.shared().chatManager?.remove(self)
NotificationCenter.default.removeObserver(self)
}
}
Expand Down Expand Up @@ -95,7 +95,7 @@ extension AgoraChatSendTextViewController {
private func sendTextMessage(_ text: String) {
let to = self.conversation?.conversationId ?? ""
let message = AgoraChatMessage(conversationID: to, from: AgoraChatClient.shared().currentUsername!, to: to, body: AgoraChatTextMessageBody(text: text), ext: [:])
AgoraChatClient.shared().chatManager.send(message, progress: nil) { sendMessage, error in
AgoraChatClient.shared().chatManager?.send(message, progress: nil) { sendMessage, error in
if error == nil {
if self.heightMap[message.messageId] ?? 0 <= 0 {
self.heightMap[message.messageId] = AgoraChatTextCell.contentHeight(message)+52
Expand Down
Loading