Latest 1.5.7
Homepage https://github.com/WatchBeam/beam-client-swift
License MIT
Platforms ios 8.2, requires ARC
Dependencies Starscream, SwiftyJSON
Authors

Build Status
CocoaPods Compatible

This is a client library for Beam written in Swift.

Features

  • Authenticate with Beam and manage your user session
  • Retrieve full data about channels, users, and other resources
  • Send and receive packets through the chat and Interactive servers
  • Complete Documentation

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8.2+ / tvOS 9.0+ (macOS and watchOS coming soon)
  • Xcode 7.3+

Installation

CocoaPods

You can add BeamAPI to your project by adding it to your Podfile.

Because BeamAPI is written in Swift, you will need to add the use_frameworks! flag in your Podfile.

platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
  pod 'BeamAPI', '~> 1.0'
end

Usage

Retrieving Channel Data

import BeamAPI

BeamClient.sharedClient.channels.getChannelWithId(252) { (channel, error) in
    guard let channel = channel else {
        return
    }

    print("(channel.token) has (channel.viewersCurrent) viewers.")
}

Connecting to Chat

import BeamAPI

class ChatReceiver: NSObject, ChatClientDelegate {

    // Connect to the channel with an id of 252
    func start() {
        let client = ChatClient(delegate: self)
        client.joinChannel(252)
    }

    // Called when a connection is made to the chat server
    func chatDidConnect() {
        print("connected to chat")
    }

    // Called when the chat server sent us a packet
    func chatReceivedPacket(packet: Packet) {
        if let packet = packet as? MessagePacket {
            print("message received: (packet.messageText)")
        }
    }

    // Called when there is a new viewer count available
    func updateWithViewers(viewers: Int) {
        print("(viewers) are watching")
    }
}

License

BeamAPI is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "BeamAPI",
    "version": "1.5.7",
    "summary": "An interface to communicate with Beam's backend.",
    "homepage": "https://github.com/WatchBeam/beam-client-swift",
    "license": "MIT",
    "authors": {
        "Jack Cook": "[email protected]"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.2"
    },
    "source": {
        "git": "https://github.com/WatchBeam/beam-client-swift.git",
        "tag": "1.5.7"
    },
    "source_files": "Pod/Classes/**/*",
    "dependencies": {
        "Starscream": [
            "~> 2.0"
        ],
        "SwiftyJSON": [
            "~> 3.1"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This