Documentation — Bolt Live Messaging API

The Bolt API (BLT) is easy to initiate and incorporate in new and existing projects. There are only two blocks to consider, that for posting changes in the current user’s (recipient) currently typed message — and that for listening to changes in the other user’s (sender) currently typed message.

Initialisation

Bolt includes a one step initialisation. It is recommended to include this in the applicationDidFinishLaunchingWithOptions method of your Application Delegate. However, as long as it is initialised before you try to interact with your database you will not face errors.

BLTSharedInstance.initializeWithID(/*Enter applicationID String*/)

The BLTMessageObject

The base class of a message in the BLT API is a BLTMessageObject. You can add a BLTMessageObject to your current messaging data structure, and update this object in your BLT Database whenever the user’s currently typed message changes.

class BLTMessageObject {
    var messageBody:String!
    var messageType:String?
    var senderID:String!
    var recipientID:String!
    var messageTime:NSDate!
}

BLTConversationManager

Listening to changes

// React to other user typing
BLTConversationManager.startListeningForMessagesWithID(“conversationID1”) { (messageObject , error) -> Void in
    if error == nil {
        let messageObject = messageObject! as BLTMessageObject
        // Deal with the change of currently typed message in your UI
    } else {
        // Deal with error in establishing connection
        print(error)
    }
}

BLTConversationManager

Posting typed message changes

// Show typed message changed
let messageObject = BLTMessageObject()
messageObject.messageBody = "messageBodyString"
messageObject.messageTime = NSDate()
messageObject.senderID = "senderIDAlphanumericString"
messageObject.recipientID = "recipientIDAlphanumericString"
BLTConversationManager.postTypedMessageChangeFromID(messageObject) { (result, error) -> () in
    if error == nil {
        let sentMessage = result! as BLTMessageObject
        print(sentMessage)
    } else {
        print(error)
    }
}

And that is all you have to do!

We do the hard work, and leave you free to build cool features with our technology!

An example project demonstrating a usage of the BLT API is available open source on our GitHub .

Disclaimer — Any similarity between the BLT API trademark and a common sandwich filling is purely coincidental, please don’t sue…