メインコンテンツまでスキップ

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.

PrerequisitesPrerequisites への直接リンク

Payment methodsPayment 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: InstallationStep 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 SDKStep 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 placementStep 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 email must be raw (unhashed) for the brand to send order confirmation.

See the Web SDK recommended attributes table for the full list. The same attributes apply to the iOS SDK.

この記事は役に立ちましたか?