Getting Started with LiveLikeSwift
This is the developer's guide to getting started with LiveLikeSwift. We will walk you through the installation and initialization steps. First, make sure that you are using a supported OS version(s):
- iOS 10
- macOS 10_12
- tvOS 10
- watchOS 3
Installation
Swift Package Manager (Recommended)
- Open your project inside of Xcode and navigate to File > Add Packages...
- Search for
[email protected]:livelike/livelike-ios-sdk.git
and select thelivelike-ios-sdk
swift package - Use the Up to Next Major Version dependency rule spanning from 2.0.0 < 3.0.0, and hit the Add Package button
CocoaPods
https://guides.cocoapods.org/using/using-cocoapods.html
Add the following to a Podfile:
target '<application-target-name>' do
use_frameworks!
pod 'LiveLikeSwift'
end
Initialization
The LiveLike object is the access point for all features. To create a LiveLike object you will need:
- A Client ID
- An Access Token
If your billing is determined by Monthly Active Users (MAUs), then at this point it is important to consider how and when LiveLikeSwift will be initialized. We recommend creating the LiveLike object as late as possible for the most accurate usage metrics.
By default, LiveLikeSwift will generate a new User Profile upon first initialization and store. it locally. For profile persistence, we recommend that you override where the user's access token is read and written using the AccessTokenStorage
protocol.
import LiveLikeSwift
class Initialization {
private var livelike: LiveLike?
init() {
var config = LiveLikeConfig(clientID: "my-client-id")
config.accessTokenStorage = self
self.livelike = LiveLike(config: config)
}
}
extension Initialization: AccessTokenStorage {
func fetchAccessToken() -> String? {
return "user-access-token"
}
func storeAccessToken(accessToken: String) { }
}
Updated about 1 year ago