Skip to content

Commit b982c41

Browse files
thomson-tclaude
authored andcommitted
feat: add selectShoppableAds API and migrate to mParticle SDK 9.0
- Add selectShoppableAds() to JS/TS API, codegen spec, iOS native bridge, and Android (no-op) - Migrate iOS native code to mParticle Apple SDK 9.0: - MPRoktEventCallback removed, use onEvent: block pattern - All MPRokt* event classes renamed to Rokt* (from RoktContracts) - Event property .placementId renamed to .identifier - MPRoktConfig -> RoktConfig via RoktConfigBuilder - MPRoktEmbeddedView -> RoktEmbeddedView - Import paths updated for mParticle_Apple_SDK_ObjC module - Add new shoppable ads event types: CartItemInstantPurchaseInitiated, CartItemInstantPurchaseFailure, InstantPurchaseDismissal, CartItemDevicePay - Backwards-compatible RoktCallback emission for onLoad/onUnLoad/etc. - Bump version to 3.0.0, iOS deployment target to 15.6 - Add shoppable ads demo button to ExpoTestApp Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 441fc7e commit b982c41

16 files changed

Lines changed: 280 additions & 168 deletions

File tree

ExpoTestApp/App.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,32 @@ export default function App() {
219219
const handleRoktBottomSheet = () =>
220220
handleRoktSelectPlacements('MSDKBottomSheetLayout');
221221

222+
const handleRoktShoppableAds = () => {
223+
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',
231+
};
232+
233+
const config = MParticle.Rokt.createRoktConfig('system');
234+
235+
addLog('Rokt: Calling selectShoppableAds');
236+
237+
MParticle.Rokt.selectShoppableAds('ConfirmationPage', attributes, config)
238+
.then((result: any) => {
239+
addLog(`Rokt selectShoppableAds success: ${JSON.stringify(result)}`);
240+
setStatus('Rokt: Shoppable Ads loaded');
241+
})
242+
.catch((error: any) => {
243+
addLog(`Rokt selectShoppableAds error: ${JSON.stringify(error)}`);
244+
setStatus(`Rokt error: ${error.message || 'Unknown error'}`);
245+
});
246+
};
247+
222248
return (
223249
<SafeAreaView style={styles.container}>
224250
<StatusBar barStyle="dark-content" />
@@ -323,6 +349,13 @@ export default function App() {
323349
>
324350
<Text style={styles.buttonText}>Bottom Sheet</Text>
325351
</TouchableOpacity>
352+
353+
<TouchableOpacity
354+
style={[styles.button, styles.roktButtonAlt]}
355+
onPress={handleRoktShoppableAds}
356+
>
357+
<Text style={styles.buttonText}>Shoppable Ads</Text>
358+
</TouchableOpacity>
326359
</View>
327360

328361
{/* Rokt Embedded Placeholder */}

ExpoTestApp/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
"prebuild": "expo prebuild --clean"
1111
},
1212
"dependencies": {
13-
"react-native-mparticle": "file:../react-native-mparticle-latest.tgz",
1413
"expo": "~54.0.25",
14+
"expo-build-properties": "~1.0.10",
1515
"expo-dev-client": "~6.0.16",
1616
"expo-status-bar": "~3.0.8",
1717
"react": "19.1.0",
18-
"react-native": "0.81.5"
18+
"react-native": "0.81.5",
19+
"react-native-mparticle": "file:.."
1920
},
2021
"devDependencies": {
2122
"@babel/core": "^7.25.2",

android/src/main/java/com/mparticle/react/rokt/MPRoktModuleImpl.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.mparticle.MpRoktEventCallback
1616
import com.mparticle.RoktEvent
1717
import com.mparticle.UnloadReasons
1818
import com.mparticle.WrapperSdk
19+
import com.mparticle.internal.Logger
1920
import com.mparticle.rokt.CacheConfig
2021
import com.mparticle.rokt.RoktConfig
2122
import kotlinx.coroutines.Job
@@ -39,6 +40,14 @@ class MPRoktModuleImpl(
3940

4041
fun getName(): String = MODULE_NAME
4142

43+
fun selectShoppableAds(
44+
identifier: String,
45+
attributes: ReadableMap?,
46+
roktConfig: ReadableMap?,
47+
) {
48+
Logger.warning("selectShoppableAds is not yet supported on Android")
49+
}
50+
4251
fun purchaseFinalized(
4352
placementId: String,
4453
catalogItemId: String,

android/src/newarch/java/com/mparticle/react/rokt/MPRoktModule.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ import com.facebook.react.bridge.ReadableType
77
import com.facebook.react.bridge.UiThreadUtil
88
import com.facebook.react.uimanager.UIManagerHelper
99
import com.mparticle.MParticle
10-
import com.mparticle.WrapperSdk
10+
import com.mparticle.internal.Logger
1111
import com.mparticle.react.NativeMPRoktSpec
1212
import com.mparticle.rokt.RoktEmbeddedView
13-
import com.mparticle.internal.Logger
1413
import java.lang.ref.WeakReference
1514
import java.util.concurrent.CountDownLatch
1615

1716
class MPRoktModule(
1817
private val reactContext: ReactApplicationContext,
1918
) : NativeMPRoktSpec(reactContext) {
20-
2119
private val impl = MPRoktModuleImpl(reactContext)
2220

2321
override fun getName(): String = impl.getName()
@@ -52,6 +50,15 @@ class MPRoktModule(
5250
)
5351
}
5452

53+
@ReactMethod
54+
override fun selectShoppableAds(
55+
identifier: String,
56+
attributes: ReadableMap?,
57+
roktConfig: ReadableMap?,
58+
) {
59+
impl.selectShoppableAds(identifier, attributes, roktConfig)
60+
}
61+
5562
@ReactMethod
5663
override fun purchaseFinalized(
5764
placementId: String,
@@ -61,7 +68,6 @@ class MPRoktModule(
6168
impl.purchaseFinalized(placementId, catalogItemId, success)
6269
}
6370

64-
6571
/**
6672
* Process placeholders from ReadableMap to a map of Widgets for use with Rokt.
6773
* This method handles the Fabric-specific view resolution.
@@ -83,8 +89,9 @@ class MPRoktModule(
8389
// Get the tag value as an integer
8490
val reactTag =
8591
when {
86-
placeholders.getType(key) == ReadableType.Number ->
92+
placeholders.getType(key) == ReadableType.Number -> {
8793
placeholders.getDouble(key).toInt()
94+
}
8895

8996
else -> {
9097
Logger.warning("Invalid view tag for key: $key")

android/src/oldarch/java/com/mparticle/react/rokt/MPRoktModule.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ class MPRoktModule(
4848
}
4949
}
5050

51+
@ReactMethod
52+
override fun selectShoppableAds(
53+
identifier: String,
54+
attributes: ReadableMap?,
55+
roktConfig: ReadableMap?,
56+
) {
57+
impl.selectShoppableAds(identifier, attributes, roktConfig)
58+
}
59+
5160
@ReactMethod
5261
override fun purchaseFinalized(
5362
placementId: String,

0 commit comments

Comments
 (0)