TelloTalk SDK is a solution for integrating chat messaging in your application.
You must have Access Key & Project Key to use this SDK in your application.
Add TTChatSDK.xcframework file provided into your application, then select you application target, in General tab, then add .framework file in Embedded Binaries
or
pod 'TTChatSDK'
or
Add https://github.com/TelloTalk/TTChatSDKSwiftPackage.git
as a swift package.
import TTChatSDK
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
do {
try TTChat.shared.setup(accessKey: "<ACCESS_KEY>", projectToken: "<PROJECT_KEY>")
} catch let error {
print(error)
}
return true
}
When you're logging in or signing up the application for the first time you need to call this, if there is error then you will get value in errorString
otherwise it will be nil
TTChat.shared.registerUser(profileId: "<ProfileId>", name: "<Name>", mobileNumber: "<Mobile Number>") { [weak self] (buddy, errorString) in
guard let self = self else { return }
}
errorString
will be nil if login
is successfull otherwise it will throw an error, After calling this method connection between server and mobile app will be started for getting messages.
do {
try TTChat.shared.login(completion: { [weak self] (errorString) in
guard let self = self else { return }
})
} catch let error {
print(error)
// might be profile id missing error
}
You can directly open corporate list, you can set title
of that list if you want otherwise passed nil
TTChat.shared.showCorporateUsers(controller: self, title: "Title")
Create Certificate and upload it to provided panel or contact [email protected]
Establishing a Certificate-Based Connection to APNs
In AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
application.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
TTChat.shared.didRegisterForRemoteNotifications(with: deviceToken)
}
Turn On Push Notifications
from Capabilities by selecting your target
TTChat.shared.getTotalUnreadMessageCount { [weak self] (count) in
guard let self = self else { return }
}
count
will be the unread messages count
NSCameraUsageDescription
- For sending images/video from cameraNSPhotoLibraryUsageDescription
- For sending images/video from photo libraryNSContactsUsageDescription
- For sending contacts and syncing contacts (if required)NSLocationWhenInUseUsageDescription
- For sending location messageNSMicrophoneUsageDescription
- For sending audio note messageTTChat.shared.settings.themeColor = .green
TTChat.shared.settings.outgoingMessageBubbleColor = .green
TTChat.shared.settings.outgoingMessageBubbleTextColor = .white
TTChat.shared.settings.messageStateIconColor = UIColor.init(white: 0.8, alpha: 1)
TTChat.shared.settings.readIconColor = UIColor(red: 0, green: 255/255, blue: 71/255, alpha: 1)
TTChat.shared.settings.timeOutgoingColor = UIColor.init(white: 0.9, alpha: 1)
TTChat.shared.settings.audioRecordButtonColor = .systemGreen
TTChat.shared.settings.sendButtonColor = .systemGreen
link |
Stars: 0 |
Last commit: 1 week ago |
Major UI and UX Improvements
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics