Getting Started
The LikeMinds Feed SDK allows you to seamlessly integrate personalized and engaging feeds into your iOS application. This can significantly enhance the user experience and drive user engagement within your app. This getting started guide will walk you through the steps to integrate it into your application.
Prerequisites
Before you begin, ensure that you have the following:
- Xcode: Make sure you have the latest version of Xcode installed on your development machine.
- Minimum iOS Version: Your project should target iOS 13.0 or later.
- CocoaPods: Ensure you have CocoaPods installed for dependency management.
Dependencies
The SDK tries to keep the list of external dependencies to a minimum, these are the dependencies currently used:
LikeMindsFeedUI
LikeMindsFeedUI doesn't depends on any external packages
LikeMindsFeedCore
LikeMindsFeed
Step-by-Step Integration Guide
Follow these steps to integrate the LikeMinds Feed SDK into your iOS application using CocoaPods:
Step 1 Install LikeMindsFeedCore via CocoaPods:
Open your project's Podfile
and add the following lines:
platform :ios, '13.0'
target 'YourProjectName' do
use_frameworks!
pod 'LikeMindsFeedCore'
end
Then, run pod install
from the terminal to install the required dependencies.
Step 2 - Set Up LikeMinds Feed:
In your AppDelegate.swift
file, import the LikeMindsFeedCore
framework and set up the LikeMinds Feed in the application(_:willFinishLaunchingWithOptions:)
method:
import LikeMindsFeedCore
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) {
LMFeedCore.shared.setupFeed(deviceId: deviceId)
}
It is advised to initiate LikeMindsFeed at the beginning of your App Cycle
Step 3 - Initialise LikeMinds Feed:
You have successfully initiated the LMFeedCore. Now, When integrating the LikeMinds Feed SDK into your application, provide API Key directly to LikeMinds Feed SDK, which will be used to initiate a user session by calling showFeed()
method from LMFeedCore.
import LikeMindsFeedCore
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) {
LMFeedCore.shared.showFeed(apiKey: "YOUR_API_KEY", username: username, uuid: userId, completionHandler: { })
}
For enhanced security, you can use Server Side User Authentication to initiate user sessions through your own server.
Step 4 - Navigation:
In the view controller where you want to display the LikeMinds Feed, import the LikeMindsFeedCore
framework and initialize the feed with the appropriate user credentials:
- Social Feed
- QnA Feed
import LikeMindsFeedCore
let username = "USER_NAME"
let uuid = "USER_UUID"
try? LMFeedCore.shared.showFeed(apiKey: apiKey, username: username, userId: userId) {[weak self] result in
switch result {
case .success:
guard let viewController = try? LMFeedSocialFeedViewModel.createModule() else {
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
alert.addAction(.init(title: "OK", style: .default))
self?.present(alert, animated: true)
return
}
let navigationController = UINavigationController(rootViewController: viewController)
UIApplication.shared.windows.first?.rootViewController = navigationController
UIApplication.shared.windows.first?.makeKeyAndVisible()
case .failure(let error):
// Show error message
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
alert.addAction(.init(title: "OK", style: .default))
self?.present(alert, animated: true)
return
}
}
import LikeMindsFeedCore
let username = "USER_NAME"
let uuid = "USER_UUID"
try? LMFeedCore.shared.showFeed(apiKey: apiKey, username: username, userId: userId) {[weak self] result in
switch result {
case .success:
guard let viewController = try? LMFeedQnAFeedViewModel.createModule() else {
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
alert.addAction(.init(title: "OK", style: .default))
self?.present(alert, animated: true)
return
}
let navigationController = UINavigationController(rootViewController: viewController)
UIApplication.shared.windows.first?.rootViewController = navigationController
UIApplication.shared.windows.first?.makeKeyAndVisible()
case .failure(let error):
// Show error message
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
alert.addAction(.init(title: "OK", style: .default))
self?.present(alert, animated: true)
return
}
}
The createModule()
method returns the view controller that displays the LikeMinds Feed. - In case of success, it sets the returned view controller as the root view controller of the application's window. - In case of failure, it displays an alert with the error message.
The view controller where you initialize the LikeMinds Feed should have a navigation controller, as the Feed requires navigation capabilities.
That's it! You have successfully integrated the LikeMinds Feed SDK into your iOS application. The next step would be to explore additional customization options or configurations provided by the SDK to tailor the Feed to your application's needs.