Create a custom SlackKit client.
Swift Package Manager
Add SlackKit as a dependency to yourPackage.swift and specify SKClient as a target dependency:
import PackageDescription
let package = Package(
name: "SampleApp",
products: [
.executable(
name: "SampleApp",
targets: ["SampleApp"]),
],
dependencies: [
.package(url: "https://github.com/pvzig/SlackKit.git", .upToNextMinor(from: "4.6.0")),
],
targets: [
.target(
name: "SampleApp",
dependencies: ["SKClient"])
]
)Carthage
Add SlackKit to yourCartfile:
github "pvzig/SlackKit"
and run
carthage bootstrap
Drag the built SKClient.framework and it's dependency SKCore.framework into your Xcode project.
CocoaPods
Add SKClient to yourPodfile:
use_frameworks!
pod 'SlackKit/SKClient'
To use the library in your project import it:
import SKClientimport SlackKitSubclass Client to create a custom SlackKit client.
class MyClient: Client {
override func notificationForEvent(_ event: Event, type: EventType) {
…
}
override func initialSetup(JSON: [String: Any]) {
…
}
}
Pass your custom client to SlackKit when adding an RTM bot:
let bot = SlackKit()
bot.addRTMBotWithAPIToken(“xoxb-SLACK_AUTH_TOKEN”, client: MyClient())