Giter VIP home page Giter VIP logo

stream-swift's Introduction

Stream Swift Client

Build Status Language: Swift 4.2 Documentation CocoaPods compatible Carthage compatible Swift Package Manager compatible

stream-swift is a Swift client for Stream.

You can sign up for a Stream account at https://getstream.io/get_started.

API Docs

API Examples

Installation

CocoaPods

For Stream, use the following entry in your Podfile:

pod 'GetStream', '~> 1.0'

Then run pod install.

In any file you'd like to use Stream in, don't forget to import the framework with import GetStream.

Swift Package Manager

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/GetStream/stream-swift.git", .upToNextMajor(from: "1.0.0"))

Carthage

Make the following entry in your Cartfile:

github "GetStream/stream-swift"

Then run carthage update.

Quick start

// Setup a shared Stream client.
Client.config = .init(apiKey: "<#ApiKey#>", appId: "<#AppId#>", token: "<#Token#>")

// Setup a Stream current user with the userId from the Token.
Client.shared.createCurrentUser() { _ in 
    // Do all your requests from here. Reload feeds and etc.
}

// Create a user feed.
let userFeed = Client.shared.flatFeed(feedSlug: "user")

// Create an Activity. You can make own Activity class or struct with custom properties.
let activity = Activity(actor: User.current!, verb: "add", object: "picture:10", foreignId: "picture:10")

userFeed?.add(activity) { result in
    // A result of the adding of the activity.
    print(result)
}

// Create a following relationship between "timeline" feed and "user" feed:
let timelineFeed = Client.shared.flatFeed(feedSlug: "timeline")

timelineFeed?.follow(toTarget: userFeed!.feedId, activityCopyLimit: 1) { result in
    print(result)
}

// Read timeline and user's post appears in the feed:
timelineFeed?.get(pagination: .limit(10)) { result in
    let response = try! result.get()
    print(response.results)
}

// Remove an activity by referencing it's foreignId
userFeed?.remove(foreignId: "picture:10") { result in
    print(result)
}

More API examples here

Credits & Contributors

Project is maintained by Alexey Bukhtin.

We continue to welcome pull requests from community members.

Copyright and License Information

Copyright (c) 2016-2018 Stream.io Inc, and individual contributors. All rights reserved.

See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.

stream-swift's People

Contributors

buh avatar tbarbugli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.