iOS SDK best practice
Mobile application performance is critical to your business. Our technology is focused on improving your customer's experience with your app. As such, screen performance is a core component of our solutions. To boost engagement and conversion rates, we employ several approaches to minimize screen load times.
SwiftUI Component
Starting from major version 4 of the Rokt iOS SDK, you can add a Rokt layout by utilizing the RoktLayout
component targeting iOS 15+. This removes the need to call Rokt.execute
and supports a more modern declarative integration using SwiftUI.
Adding the component
import SwiftUI
import Rokt_Widget
struct OrderConfirmationSwiftUI: View {
let attributes: [String: String]
let pageIdentifier: String
let location: String
// if application supports only Light Mode.
let roktConfig = RoktConfig.Builder()
.colorMode(.light)
.build()
var body: some View {
VStack(alignment: .leading) {
RoktLayout(sdkTriggered: true,
viewName: pageIdentifier,
locationName: location, // If using an embedded layout
attributes: attributes,
config: roktConfig,
onLoad: {
// Optional callback for when the Rokt placement loads
}, onUnLoad: {
// Optional callback for when the Rokt placement unloads
},onShouldShowLoadingIndicator: {
// Optional callback to show a loading indicator
}, onShouldHideLoadingIndicator: {
// Optional callback to hide a loading indicator
})
}.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
}
}
You can use the RoktLayout
component for both embedded and overlay layouts.
Using App Configurations
Applications can now send configuration settings from their own application environment. This allows Rokt SDK to use application custom configurations instead of relying solely on system defaults.
// if application supports only Light Mode.
let roktConfig = RoktConfig.Builder()
.colorMode(.light)
.build()
Rokt.execute(
// other params,
config: roktConfig,
)
ColorMode object
Value | Description |
---|---|
light | Application is in Light Mode |
dark | Application is in Dark Mode |
system | Application defaults to System Color Mode |
For more information see how-to section.