Stream your Live content from your iOS App.
The Live iOS SDK enables you to display your Live content inside your iOS App.
The live SDK package is separated in two distinct targets: Live
which contains all the "core" code and LiveUI
containing UI elements.
In Xcode, select File
> Swift packages
> Add Package Dependency
and enter Live SDK github url below:
https://github.com/pbj-apps/Live-ios-sdk
You need to initialize the Live
SDK with your credentials on App start.
A good place to do this is typically the AppDelegate
.
import Live
// [...]
let live = LiveSDK.initialize(
apiKey: "YOUR_API_KEY",
environment: .dev,
logLevels: .debug)
environment
is optional and defaults to.prod
.logLevels
is also optional and defaults to.off
.
The whole Live
api is accessed via this live
object which exposes a classic Combine api returning AnyPublisher<Result, Error>
Before querying any data, you need to authenticate the SDK. This process is asynchonous.
live.authenticateAsGuest()
.sink {
// SDK is now authenticated \o/
}
.store(in: &cancellables)
Fetch all VoD Categories
live.fetchVodCategories().sink { categories in
// categories
}
.store(in: &cancellables)
Fetch a specific VoD Category
live.fetch(category: category).sink { category in
// category
}
.store(in: &cancellables)
Fetch all playlists
live.fetchVodPlaylists().sink { playlists in
// playlists
}
.store(in: &cancellables)
Fetch a specific playlist
live.fetch(playlist: playlist).sink { playlist in
// playlist
}
.store(in: &cancellables)
Fetch all VoD Videos
live.fetchVodVideos().sink { videos in
// videos
}
.store(in: &cancellables)
Fetch a specific VoD Video
live.fetch(video: vodVideo).sink { video in
// video
}
.store(in: &cancellables)
Search Vod Videos only
live.searchVodVideos(query: query).sink { videos in
// videos
}
.store(in: &cancellables)
Search Vod Videos & Playlists
live.searchVod(query: query).sink { vodItems in
// vodItems (VodVideo & VodPlaylist)
}
.store(in: &cancellables)
Fetch all episodes
live.fetchEpisodes().sink { episodes in
// episodes
}
.store(in: &cancellables)
Fetch a specific episode
live.fetch(episode: Episode).sink { episode in
// episode
}
.store(in: &cancellables)
In order to have access to UI elements, you will need to import LiveUI
.
UI components provided are 100% build with SwiftUI. For apps that haven't made the switch yet, we also provide a UIKit compatible api.
SwiftUI
LivePlayer(episode: episode, close: { })
UIKIt
let livePlayerVC = LivePlayerViewController(episode: episode)
livePlayerVC.delegate = self
present(livePlayerVC, animated: true, completion: nil)
Here showId
is optional and without it, it would play the first live stream found.
SwiftUI
VodPlayer(url: vodUrl, close: {})
UIKit
let vodPlayerVC = VodPlayerViewController(url: vodUrl)
vodPlayerVC.delegate = self
present(vodPlayerVC, animated: true, completion: nil)
Checkout the example App provided in this repository to see a typical integration. With the test app, you can input your Organization api key and battle test your own environment.
Create a github issue and we'll help you from there ❤️