Skip to content

notbakaneko/SwiftSlackPoster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftSlackPoster

A Swift client that posts messages to incoming webhooks on Slack. This is a basic client that just posts attachments to Slack as-is; it does no formatting whatsoever.

Example

I've not actually run nor tried to compile this example :3

if let url = NSURL("https://hooks.slack.com/services/your-incoming-webhook-url-goes-here") {
  let slackPoster = SlackPoster(url: url)
  slackPoster.username = "username to appear on messages"
  
  var fields = [
    Field(title: "Field 1", value: "A short field"),
    Field(title: "Field 2", value: "A long field that is not actually very long", short: false)
  ]
  
  var attachment = Attachment(
    text: "optional text",
    pretext: "optional pretext",
    fallback: "required fallback message",
    color: "#36a64f", // Can either be one of 'good', 'warning', 'danger', or any hex color code
    fields: fields
  )
  
  // posts asynchronously; does not perform and error handling yet :)
  slackPoster.post(attachment)
}

About

Posts messages to incoming webhooks on Slack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published