iOS
Seamlessly integrate Monterosa’s interactive Experiences into your iOS app.
Step by step guide
1
Load Monterosa SDK
https://<package-username>:<package-token>@gitlab.com/monterosa-sdk/ios.gittarget 'MyApp' do
username = "<YOUR USERNAME>"
token = "<YOUR TOKEN>"
version = "0.17.2"
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
end2
Configure Monterosa SDK Core
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>")
...
}
}3
Create the Experience View
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 = true4
Listen to Experience State Changes
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

