CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Feb 2018 |
SPMSupports SPM | ✗ |
Maintained by Srinvas Vasadi.
This SDK allows you to talk to Bots over a web socket.
- SDK app credentials (Create your SDk app in bot admin console to aquire the client id and client secret.
- jwt assertion generation methodology. ex: service which will be used in the assertion function injected as part of obtaining the connection.
Run pod install in the KoreBotSDKDemo project folder.
Open KoreBotSDKDemo.xworkspace in Xcode.
Run the app in xcode
import KoreBotSDK
var self.botClient: BotClient!
let token: String = "bearer Y6w*******************"
let botInfo: NSDictionary = ["chatBot":"Kora","taskBotId":"st-******"]
self.botClient = BotClient(botInfoParameters: botInfo)
a. You need to have secure token service hosted in your environment which returns the JWT token.
b. Replace "jwtUrl" variable value with your STS endpoint in constants.swift file
c. self.botClient.connectAsAuthenticatedUser(jwtToken, success: { [weak self] (botClient) in
// listen to RTM events
}, failure: { (error) in
})
let clientId: String = "YOUR_SDK_CLIENTID"
self.botClient.connectAsAnonymousUser(clientId, success: { [weak self] (client) in
// listen to RTM events
}, failure: { (error) in
})
botClient.sendMessage("Tweet hello", options: [])
self.botClient.onMessage = { [weak self] (object) in
}
self.botClient.onMessageAck = { (ack) in
}
self.botClient.connectionDidClose = { (code) in
}
self.botClient.connectionDidEnd = { (code, reason, error) in
}
self.botClient.subscribeToNotifications(deviceToken, success: { (staus) in
// do something
}, failure: { (error) in
})
self.botClient.unsubscribeToNotifications(deviceToken, success: { (staus) in
// do something
}, failure: { (error) in
})
a. As a logged in user
self.botClient.connectAsAuthenticatedUser(jwtToken, success: { [weak self] (botClient) in
botClient.connectionWillOpen = { () in
}
botClient.connectionDidOpen = { () in
}
botClient.onConnectionError = { (error) in
}
botClient.onMessage = { (object) in
}
botClient.onMessageAck = { (ack) in
}
botClient.connectionDidClose = { (code) in
}
botClient.connectionDidEnd = { (code, reason, error) in
}
}, failure: { (error) in
})
b. As a anonymous user
self.botClient.connectAsAnonymousUser(clientId, success: { [weak self] (botClient) in
botClient.connectionWillOpen = { () in
}
botClient.connectionDidOpen = { () in
}
botClient.onConnectionError = { (error) in
}
botClient.onMessage = { (object) in
}
botClient.onMessageAck = { (ack) in
}
botClient.connectionDidClose = { (code) in
}
botClient.connectionDidEnd = { (code, reason, error) in
}
}, failure: { (error) in
})
Copyright © Kore, Inc. MIT License; see LICENSE for further details.