Skip to content

Commit aa42c0d

Browse files
Add Implementtion Guide
1 parent 0fa5686 commit aa42c0d

2 files changed

Lines changed: 73 additions & 8 deletions

File tree

ExpoTestApp/App.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,32 @@ export default function App() {
221221

222222
const handleRoktShoppableAds = () => {
223223
const attributes = {
224-
email: 'user@example.com',
225-
firstname: 'John',
226-
lastname: 'Doe',
227-
confirmationref: 'ORDER-12345',
228-
amount: '99.99',
229-
currency: 'USD',
230-
paymenttype: 'credit_card',
224+
country: "US",
225+
shippingstate: "NY",
226+
shippingzipcode: "10001",
227+
firstname: "Jenny",
228+
stripeApplePayAvailable: "true",
229+
last4digits: "4444",
230+
shippingaddress1: "123 Main St",
231+
colormode: "LIGHT",
232+
billingzipcode: "07762",
233+
paymenttype: "ApplePay",
234+
shippingcountry: "US",
235+
sandbox: "true",
236+
shippingaddress2: "Apt 4B",
237+
confirmationref: "ORD-12345",
238+
shippingcity: "New York",
239+
newToApplePay: "false",
240+
applePayCapabilities: "true",
241+
lastname: "Smith",
242+
email: "jenny.smith@example.com"
231243
};
232244

233245
const config = MParticle.Rokt.createRoktConfig('system');
234246

235247
addLog('Rokt: Calling selectShoppableAds');
236248

237-
MParticle.Rokt.selectShoppableAds('ConfirmationPage', attributes, config)
249+
MParticle.Rokt.selectShoppableAds('StgRoktShoppableAds', attributes, config)
238250
.then((result: any) => {
239251
addLog(`Rokt selectShoppableAds success: ${JSON.stringify(result)}`);
240252
setStatus('Rokt: Shoppable Ads loaded');

ExpoTestApp/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,64 @@ The app also includes Rokt placement testing via the mParticle Rokt kit:
8080
- **Embedded**: Loads an embedded Rokt placement that renders in-line within the app content. The placement appears in the designated placeholder area below the buttons.
8181
- **Overlay**: Loads a full-screen overlay Rokt placement that appears on top of the app content.
8282
- **Bottom Sheet**: Loads a bottom sheet Rokt placement that slides up from the bottom of the screen.
83+
- **Shoppable Ads**: Calls `MParticle.Rokt.selectShoppableAds` with a staging placement identifier and checkout-style attributes (see implementation guide below).
8384

8485
The Rokt section also demonstrates:
8586

8687
- Platform-specific attributes (iOS vs Android configurations)
8788
- Rokt event listeners for callbacks and placement events
8889
- Using `RoktLayoutView` as an embedded placeholder component
8990

91+
### Implementation guide: Shoppable Ads (`selectShoppableAds`) and iOS payment extensions
92+
93+
This mirrors the recent SDK work (Shoppable Ads API on iOS and the Expo test app wiring) and how to pair it with native payment registration.
94+
95+
#### JavaScript: `selectShoppableAds`
96+
97+
Use `MParticle.Rokt.selectShoppableAds(identifier, attributes, roktConfig?)` when you need the Shoppable Ads experience instead of `selectPlacements`.
98+
99+
- **identifier**: Rokt page / placement identifier configured for your account (the Expo test app uses a staging example such as `StgRoktShoppableAds`; replace with your production identifier).
100+
- **attributes**: String key/value pairs passed to Rokt (shipping, billing, payment hints, sandbox flags, etc.). The demo in `App.tsx` includes fields like `country`, `shippingstate`, `paymenttype`, `stripeApplePayAvailable`, `applePayCapabilities`, and `sandbox`—adjust to match your integration and Rokt’s attribute contract.
101+
- **roktConfig**: Optional; the demo uses `MParticle.Rokt.createRoktConfig('system')` for color mode. Add a cache config if you use caching elsewhere.
102+
103+
Example (same pattern as `ExpoTestApp/App.tsx`):
104+
105+
```javascript
106+
const config = MParticle.Rokt.createRoktConfig('system');
107+
108+
MParticle.Rokt.selectShoppableAds('YOUR_PLACEMENT_ID', attributes, config)
109+
.then(() => { /* success */ })
110+
.catch((error) => { /* handle */ });
111+
```
112+
113+
Listen for `RoktCallback` and `RoktEvents` on `RoktEventManager` to observe load/unload and Shoppable Ads–related events emitted by the native bridge.
114+
115+
**Android:** `selectShoppableAds` is not implemented on Android yet; the native module logs a warning and does not run the Shoppable Ads flow. Plan for iOS-only behavior until Android support ships.
116+
117+
#### iOS native: `RoktStripePaymentExtension` (payment extensions)
118+
119+
Shoppable Ads flows that use Apple Pay / Stripe integration expect a **payment extension** to be registered on mParticle’s Rokt interface after the SDK starts.
120+
121+
In `ios/MParticleExpoTest/AppDelegate.swift`, the test app:
122+
123+
1. Imports the Stripe payment extension module provided with the Rokt / kit stack: `import RoktStripePaymentExtension`.
124+
2. After `MParticle.sharedInstance().start(with: mParticleOptions)`, constructs `RoktStripePaymentExtension(applePayMerchantId: "...")` with your **Apple Pay merchant ID** (replace `merchant.dummy` with your real `merchant.*` identifier from Apple Developer).
125+
3. Registers it: `MParticle.sharedInstance().rokt.register(paymentExtension)`.
126+
127+
```swift
128+
import RoktStripePaymentExtension
129+
130+
// After MParticle.sharedInstance().start(with: mParticleOptions):
131+
if let paymentExtension = RoktStripePaymentExtension(applePayMerchantId: "merchant.your.id") {
132+
MParticle.sharedInstance().rokt.register(paymentExtension)
133+
}
134+
```
135+
136+
**Important:**
137+
138+
- The Expo config plugin **does not** generate the payment extension block today. After `expo prebuild`, add or merge this code into `AppDelegate.swift` (inside the same app launch path as mParticle init). If you regenerate native projects with `--clean`, re-apply this snippet.
139+
- Ensure the **mParticle Rokt kit** (and transitive Rokt dependencies) are installed so `RoktStripePaymentExtension` resolves—same as configuring `iosKits`: `["mParticle-Rokt"]` in `app.json`.
140+
90141
All activity is logged in the Activity Log section at the bottom of the screen.
91142

92143
## Verifying Plugin Integration
@@ -116,6 +167,8 @@ Check `ios/MParticleExpoTest/AppDelegate.swift` for:
116167
MParticle.sharedInstance().start(with: mParticleOptions)
117168
```
118169

170+
For Shoppable Ads with Apple Pay / Stripe, you may also need to register `RoktStripePaymentExtension` after `start`—see **Implementation guide: Shoppable Ads (`selectShoppableAds`) and iOS payment extensions** above.
171+
119172
#### Objective-C AppDelegate (Legacy)
120173

121174
For older Expo SDK versions, check `ios/MParticleExpoTest/AppDelegate.mm` for:

0 commit comments

Comments
 (0)