iOS SDK Integration
This guide covers how to integrate the Rokt iOS SDK into your native iOS app to enable Shoppable Ads. For the general Rokt iOS SDK reference, see integrating and initializing the iOS SDK.
IMPORTANT: These instructions require iOS development resources. Contact your Rokt account manager for your Rokt Tag ID.
PrerequisitesDirect link to Prerequisites
- iOS 15.0+ deployment target.
- A Rokt account with an active Rokt Tag ID.
- Familiarity with the Rokt iOS SDK documentation.
Payment methodsDirect link to Payment methods
In addition to the below instructions, you will also need to integrate with at least one Payment Method to allow your customers to complete a purchase.
NOTE: It is highly recommended to support Apple Pay on iOS. Apple Pay requires additional setup including PaymentKit registration. See the Apple Pay guide for iOS-specific configuration.
Step 1: InstallationDirect link to Step 1: Installation
Add the Rokt iOS SDK via Swift Package Manager. In Xcode, go to File > Add Package Dependencies and enter the repository URL:
https://github.com/ROKT/rokt-sdk-ios.git
Select Rokt_Widget as a package product for your target. If you plan to support Apple Pay, also add Rokt_Stripe_Payment_Kit (see the Apple Pay guide for details).
NOTE: For full installation options and version requirements, see the iOS SDK installation guide.
Step 2: Initialize the SDKDirect link to Step 2: Initialize the SDK
Initialize the Rokt SDK in your app delegate or initial view controller. For the full initialization reference, see initializing the iOS SDK.
import Rokt_Widget
Rokt.initWith(roktTagId: "<ROKT_TAG_ID>") { status in
print("Rokt SDK initialized with status: \(status)")
}
Step 3: Add a placementDirect link to Step 3: Add a placement
Present the Shoppable Ads placement on your confirmation screen using an overlay placement. For full placement options, see adding overlay placements.
import Rokt_Widget
let attributes: [String: String] = [
"email": "j.smith@example.com",
"firstname": "Jane",
"lastname": "Smith",
"partnerpaymentreference": "ORD-8829-XK2",
"last4digits": "4242",
"paymenttype": "visa",
"shippingaddress1": "123 Main St",
"shippingcity": "Brooklyn",
"shippingstate": "NY",
"shippingzipcode": "11201",
"shippingcountry": "US",
"amount": "52.25",
"currency": "USD",
"confirmationref": "TXN-20250217-001",
]
Rokt.execute(
viewName: "confirmation_page",
attributes: attributes,
placements: [:], // Empty for overlay placements
onLoad: {
print("Rokt placement loaded")
},
onUnLoad: {
print("Rokt placement unloaded")
},
onShouldShowLoadingIndicator: {
// Show loading state
},
onShouldHideLoadingIndicator: {
// Hide loading state
}
)
NOTE: Pass the same attributes described in the Web SDK integration recommended attributes table. The
Recommended attributesDirect link to Recommended attributes
See the Web SDK recommended attributes table for the full list. The same attributes apply to the iOS SDK.