iOS
Seamlessly integrate Monterosa’s interactive Experiences into your iOS app.
This quick-start outlines how to integrate the Monterosa Interaction SDK in your iOS app to enable real-time interactions. The SDK allows for easy implementation of interactive features such as live polls, quizzes, and more. Setting up requires both actions in your app and updates in the Monterosa Interaction Cloud platform.
Step by step guide
Load Monterosa SDK
Add the Monterosa iOS SDK via Swift Package Manager or CocoaPods.
If you use Swift Package Manager, add the following GIT repository URL as a new package dependency in Xcode:
https://<package-username>:<package-token>@gitlab.com/monterosa-sdk/ios.gitYou can request access to the iOS SDK via [email protected] or your account manager. This will provide you with a username and token.
Finally, select MonterosaSDKCore and MonterosaSDKLauncherKit from the list of available Package Products.
If you use CocoaPods, add the following to your app target in your Podfile
Copy
target 'MyApp' do
username = "<YOUR USERNAME>"
token = "<YOUR TOKEN>"
version = "0.16.18"
url = "https://#{username}:#{token}@gitlab.com/monterosa-sdk/ios.git"
pod 'MonterosaSDKCommon', :git => url, :tag => version
pod 'MonterosaSDKConnectKit', :git => url, :tag => version
pod 'MonterosaSDKCore', :git => url, :tag => version
pod 'MonterosaSDKLauncherKit', :git => url, :tag => version
pod 'MonterosaSDKIdentifyKit', :git => url, :tag => version
endConfigure Monterosa SDK Core
Once you have access to the SDK, you'll have to configure it during the startup of your application, so it is able to access your project. For that, you'll need a static host and a project id, which can be retrieved in Studio.
import UIKit
import MonterosaSDKCore
@UIApplicationMain
class AppDelegate: UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
Core.configure(host: "<static host>", projectId: "<project id>")
...
}
}Create the Experience View
All Projects are associated with an App, also known as an Experience.
You will need to obtain an Experience View and then place it in your views:
let experience = Launcher.getExperience()
<yourView>.addSubview(experience)
// You need to ensure you layout the experience correctly
// For instance, to display on full screen using autolayout,
// you'll need something like this:
experience.translatesAutoresizingMaskIntoConstraints = false
experience.topAnchor.constraint(equalTo: <yourView>.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
experience.bottomAnchor.constraint(equalTo: <yourView>.bottomAnchor, constant: 0).isActive = true
experience.leadingAnchor.constraint(equalTo: <yourView>.leadingAnchor, constant: 0).isActive = true
experience.trailingAnchor.constraint(equalTo: <yourView>.trailingAnchor, constant: 0).isActive = trueListen to Experience State Changes
The ExperienceViewDelegate enables monitoring and handling of lifecycle state changes, messages, and errors in your Experience when necessary.
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
...
let experience = Launcher.getExperience()
experience.delegate = self
...
view.addSubview(experience)
// You need to ensure the experience is laid out however you see fit.
// For instance, could use autolayout constraints, or setting
// its frame
}
}extension MyViewController: ExperienceViewDelegate {
func didStartLoading(experienceView: ExperienceView) {
// Called when Experience has began loading
}
func didEndLoading(experienceView: ExperienceView) {
// Called when Experience has finished loading
}
func didFailLoading(experienceView: ExperienceView, error: Error) {
// Called when Experience has failed loading
}
func didBecomeReady(experienceView: ExperienceView) {
// Called when Experience is ready to receive messages.
}
func didReceiveMessage(experienceView: ExperienceView, message: MessageData) {
// Receive messages sent by Experience.
}
// [...]
// Implementation of the rest of ExperienceViewDelegate
// [...]
}Last updated

