Skip to content

Commit 27e482c

Browse files
thomson-tclaude
andauthored
docs: Document MPRoktEvent → RoktEvent type change in events method migration (#704)
* docs: Update events method migration to document MPRoktEvent → RoktEvent type change The events:onEvent: callback parameter type changed from MPRoktEvent to RoktEvent (from RoktContracts) but the migration guide didn't reflect this. Add before/after examples for both ObjC and Swift, and note that all MPRokt methods are now directly accessible without a separate interop import. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: Add import changes section for ObjC RoktContracts and Swift single-import ObjC callers need `@import RoktContracts;` to use RoktEvent types in onEvent callbacks. Swift callers only need `import mParticle_Apple_SDK`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 30e9842 commit 27e482c

1 file changed

Lines changed: 56 additions & 8 deletions

File tree

MIGRATING.md

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,29 @@ The `MPRokt` interface has been updated to align with the Rokt SDK 5.0.x API. Th
340340
- A new `globalEvents:` method has been added for subscribing to global Rokt events
341341
- New `registerPaymentExtension:` and `selectShoppableAds:` methods have been added for Shoppable Ads support
342342

343+
#### Import Changes
344+
345+
Since event types now come from the `RoktContracts` library instead of the SDK itself, the import requirements have changed:
346+
347+
**Objective-C:**
348+
349+
Objective-C callers must add `@import RoktContracts;` to access `RoktEvent` types (e.g., `RoktPlacementReady`, `RoktShowLoadingIndicator`) used in the `onEvent:` callbacks:
350+
351+
```objective-c
352+
@import mParticle_Apple_SDK_ObjC;
353+
@import RoktContracts;
354+
```
355+
356+
**Swift:**
357+
358+
A single import provides access to all `MPRokt` methods and `RoktEvent` types — no additional imports are needed:
359+
360+
```swift
361+
import mParticle_Apple_SDK
362+
```
363+
364+
> **Note:** In previous betas, Swift callers needed a second `import mParticle_Rokt_Swift` to access MPRokt APIs that use `RoktContracts` types. This is no longer required.
365+
343366
#### Migration Steps
344367

345368
##### selectPlacements Method
@@ -457,28 +480,53 @@ MParticle.sharedInstance().rokt.selectPlacements("checkout",
457480
458481
Note: The method signature remains the same, but the parameter name has changed from `placementId:` to `identifier:`. If you're using named parameters, update accordingly.
459482
460-
##### events Method (Swift)
483+
##### events Method
484+
485+
The `events:onEvent:` method name is unchanged, but the callback parameter type has changed from `MPRoktEvent` to `RoktEvent` (from the `RoktContracts` library). This aligns with the same event types used by `selectPlacements:onEvent:` and the Rokt SDK directly.
486+
487+
**Before (Objective-C):**
488+
489+
```objective-c
490+
[[MParticle sharedInstance].rokt events:@"checkout" onEvent:^(MPRoktEvent * _Nonnull event) {
491+
// Handle event
492+
}];
493+
```
494+
495+
**After (Objective-C):**
461496

462-
In Swift, `events(_:onEvent:)` is not directly importable due to the `RoktEvent` block parameter. Use the `subscribeToPlacementEvents(_:onEvent:)` interop method instead.
497+
```objective-c
498+
[[MParticle sharedInstance].rokt events:@"checkout" onEvent:^(RoktEvent * _Nonnull event) {
499+
if ([event isKindOfClass:[RoktPlacementReady class]]) {
500+
// Handle placement ready
501+
} else if ([event isKindOfClass:[RoktPlacementClosed class]]) {
502+
// Handle placement closed
503+
}
504+
}];
505+
```
463506
464507
**Before (Swift):**
465508
466509
```swift
467-
MParticle.sharedInstance().rokt.events("checkout") { event in
510+
MParticle.sharedInstance().rokt.events("checkout") { (event: MPRoktEvent) in
468511
// Handle event
469512
}
470513
```
471514

472515
**After (Swift):**
473516

474517
```swift
475-
MParticle.sharedInstance().rokt.subscribeToPlacementEvents("checkout") { event in
476-
// Handle event
518+
MParticle.sharedInstance().rokt.events("checkout") { event in
519+
switch event {
520+
case is RoktEvent.PlacementReady:
521+
// Handle placement ready
522+
case is RoktEvent.PlacementClosed:
523+
// Handle placement closed
524+
default:
525+
break
526+
}
477527
}
478528
```
479529

480-
> **Note:** Objective-C callers are unaffected — `events:onEvent:` remains available in ObjC unchanged.
481-
482530
##### New globalEvents Method
483531

484532
The new `globalEvents:` method allows you to subscribe to global Rokt events from all sources, including events not associated with a specific view (such as `InitComplete`).
@@ -530,7 +578,7 @@ In Objective-C, use the flat class name; in Swift, use the nested form `RoktEven
530578
- `RoktEmbeddedSizeChanged` provides `identifier` and `updatedHeight` properties
531579
- Shoppable Ads placements emit additional events: `RoktEvent.CartItemInstantPurchase`, `RoktEvent.CartItemInstantPurchaseFailure`, `RoktEvent.InstantPurchaseDismissal`, and `RoktEvent.CartItemDevicePay`
532580
- Remove any references to `MPRoktEventCallback` and `MPRoktEvent` subclasses from your code
533-
- Swift callers use the interop extension in `MPRokt+SwiftInterop.swift` to access `registerPaymentExtension` and `selectShoppableAds`
581+
- All `MPRokt` methods are directly accessible in both Objective-C and Swift — no separate interop import needed
534582
- Calling `selectShoppableAds` automatically logs a `selectShoppableAds` custom event to mParticle
535583

536584
## Migrating from versions < 8.0.0

0 commit comments

Comments
 (0)