|
1 | 1 |  |
2 | 2 | ##iOS/OS X Slack Client Library |
3 | 3 | ###Description |
4 | | -This is a Slack client library for iOS and OS X written in Swift. It's intended to expose all of the functionality of Slack's [Real Time Messaging API](https://api.slack.com/rtm). |
| 4 | +This is a Slack client library for iOS and OS X written in Swift. It's intended to expose all of the functionality of Slack's [Real Time Messaging API](https://api.slack.com/rtm) as well as the [web APIs](https://api.slack.com/web) that are accessible by [bot users](https://api.slack.com/bot-users). |
5 | 5 |
|
6 | 6 | ###Installation |
7 | | -####Swift Package Manager (Swift 2.2 and up) |
| 7 | +####Swift Package Manager |
8 | 8 | Add SlackKit to your Package.swift |
9 | 9 |
|
10 | 10 | ```swift |
@@ -37,17 +37,88 @@ import SlackKit |
37 | 37 | ###Usage |
38 | 38 | To use SlackKit you'll need a bearer token which identifies a single user. You can generate a [full access token or create one using OAuth 2](https://api.slack.com/web). |
39 | 39 |
|
40 | | -Once you have a token, give it to the Client: |
| 40 | +Once you have a token, initialize a client instance using it: |
41 | 41 | ```swift |
42 | | -Client.sharedInstance.setAuthToken("YOUR_SLACK_AUTH_TOKEN") |
| 42 | +let client = Client(apiToken: "YOUR_SLACK_API_TOKEN") |
| 43 | + |
43 | 44 | ``` |
44 | | -and connect: |
| 45 | + |
| 46 | +If you want to receive messages from the Slack RTM API, connect to it. |
45 | 47 | ```swift |
46 | | -Client.sharedInstance.connect() |
| 48 | +client.connect() |
47 | 49 | ``` |
| 50 | + |
48 | 51 | Once connected, the client will begin to consume any messages sent by the Slack RTM API. |
49 | 52 |
|
| 53 | +####Web API Methods |
| 54 | +SlackKit currently supports the a subset of the Slack Web APIs that is available to bot users: |
| 55 | + |
| 56 | +- api.test |
| 57 | +- auth.test |
| 58 | +- channels.history |
| 59 | +- channels.info |
| 60 | +- channels.list |
| 61 | +- channels.mark |
| 62 | +- channels.setPurpose |
| 63 | +- channels.setTopic |
| 64 | +- chat.delete |
| 65 | +- chat.postMessage |
| 66 | +- chat.update |
| 67 | +- emoji.list |
| 68 | +- files.delete |
| 69 | +- files.upload |
| 70 | +- groups.close |
| 71 | +- groups.history |
| 72 | +- groups.info |
| 73 | +- groups.list |
| 74 | +- groups.mark |
| 75 | +- groups.open |
| 76 | +- groups.setPurpose |
| 77 | +- groups.setTopic |
| 78 | +- im.close |
| 79 | +- im.history |
| 80 | +- im.list |
| 81 | +- im.mark |
| 82 | +- im.open |
| 83 | +- mpim.close |
| 84 | +- mpim.history |
| 85 | +- mpim.list |
| 86 | +- mpim.mark |
| 87 | +- mpim.open |
| 88 | +- pins.add |
| 89 | +- pins.list |
| 90 | +- pins.remove |
| 91 | +- reactions.add |
| 92 | +- reactions.get |
| 93 | +- reactions.list |
| 94 | +- reactions.remove |
| 95 | +- rtm.start |
| 96 | +- stars.add |
| 97 | +- stars.remove |
| 98 | +- team.info |
| 99 | +- users.getPresence |
| 100 | +- users.info |
| 101 | +- users.list |
| 102 | +- users.setActive |
| 103 | +- users.setPresence |
| 104 | + |
| 105 | +They can be accessed through a Client object’s `webAPI` property: |
| 106 | +```swift |
| 107 | +client.webAPI.authenticationTest({ |
| 108 | +(authenticated) -> Void in |
| 109 | + print(authenticated) |
| 110 | + }){(error) -> Void in |
| 111 | + print(error) |
| 112 | +} |
| 113 | +``` |
| 114 | + |
50 | 115 | ####Delegate methods |
| 116 | + |
| 117 | +To receive delegate callbacks for certain events, register an object as the delegate for those events: |
| 118 | +```swift |
| 119 | +client.slackEventsDelegate = self |
| 120 | +``` |
| 121 | + |
51 | 122 | There are a number of delegates that you can set to receive callbacks for certain events. |
52 | 123 |
|
53 | 124 | #####SlackEventsDelegate |
@@ -138,18 +209,6 @@ func subteamSelfAdded(subteamID: String) |
138 | 209 | func subteamSelfRemoved(subteamID: String) |
139 | 210 | ``` |
140 | 211 |
|
141 | | -###Examples |
142 | | -####Sending a Message: |
143 | | -```swift |
144 | | -Client.sharedInstance.sendMessage(message: "Hello, world!", channelID: "CHANNEL_ID") |
145 | | -``` |
146 | | - |
147 | | -####Print a List of Users in a Channel: |
148 | | -```swift |
149 | | -let users = Client.sharedInstance.channels?["CHANNEL_ID"]?.members |
150 | | -print(users) |
151 | | -``` |
152 | | - |
153 | 212 | ###Get In Touch |
154 | 213 | [@pvzig](https://twitter.com/pvzig) |
155 | 214 |
|
|
0 commit comments