@@ -34,11 +34,25 @@ @implementation MPRoktConfig
3434
3535@implementation MPRokt
3636
37+ // / Displays a Rokt ad placement with the specified identifier and user attributes.
38+ // / This is a convenience method that calls the full selectPlacements method with nil for optional parameters.
39+ // / - Parameters:
40+ // / - identifier: The Rokt placement identifier configured in the Rokt dashboard (e.g., "checkout_confirmation")
41+ // / - attributes: Optional dictionary of user attributes to pass to Rokt (e.g., email, firstName, etc.)
3742- (void )selectPlacements : (NSString *)identifier
3843 attributes : (NSDictionary <NSString *, NSString *> * _Nullable)attributes {
3944 [self selectPlacements: identifier attributes: attributes embeddedViews: nil config: nil callbacks: nil ];
4045}
4146
47+ // / Displays a Rokt ad placement with full configuration options.
48+ // / This method handles user identity synchronization, attribute mapping, and forwards the request to the Rokt Kit.
49+ // / Device identifiers (IDFA/IDFV) are automatically added if available.
50+ // / - Parameters:
51+ // / - identifier: The Rokt placement identifier configured in the Rokt dashboard
52+ // / - attributes: Optional dictionary of user attributes (email, firstName, etc.). Attributes will be mapped according to dashboard configuration.
53+ // / - embeddedViews: Optional dictionary mapping placement identifiers to embedded view containers for inline placements
54+ // / - config: Optional Rokt configuration object (e.g., for dark mode or custom styling)
55+ // / - callbacks: Optional callback handlers for Rokt events (selection, display, completion, etc.)
4256- (void )selectPlacements : (NSString *)identifier
4357 attributes : (NSDictionary <NSString *, NSString *> * _Nullable)attributes
4458 embeddedViews : (NSDictionary <NSString *, MPRoktEmbeddedView *> * _Nullable)embeddedViews
@@ -97,6 +111,12 @@ - (void)selectPlacements:(NSString *)identifier
97111 }];
98112}
99113
114+ // / Notifies Rokt that a purchase from a placement offer has been finalized.
115+ // / Call this method to inform Rokt about the completion status of an offer purchase initiated from a placement.
116+ // / - Parameters:
117+ // / - placementId: The identifier of the placement where the offer was displayed
118+ // / - catalogItemId: The identifier of the catalog item that was purchased
119+ // / - success: Whether the purchase was successful (YES) or failed (NO)
100120- (void )purchaseFinalized : (NSString * _Nonnull)placementId catalogItemId : (NSString * _Nonnull)catalogItemId success : (BOOL )success {
101121 dispatch_async (dispatch_get_main_queue (), ^{
102122 // Forwarding call to kits
@@ -114,6 +134,11 @@ - (void)purchaseFinalized:(NSString * _Nonnull)placementId catalogItemId:(NSStri
114134 });
115135}
116136
137+ // / Registers a callback to receive events from a specific Rokt placement.
138+ // / Use this to listen for events like placement shown, offer selected, placement closed, etc.
139+ // / - Parameters:
140+ // / - identifier: The Rokt placement identifier to listen for events from
141+ // / - onEvent: Callback block that receives MPRoktEvent objects when placement events occur
117142- (void )events : (NSString * _Nonnull)identifier onEvent : (void (^ _Nullable)(MPRoktEvent * _Nonnull))onEvent {
118143 dispatch_async (dispatch_get_main_queue (), ^{
119144 // Forwarding call to kits
@@ -131,6 +156,8 @@ - (void)events:(NSString * _Nonnull)identifier onEvent:(void (^ _Nullable)(MPRok
131156 });
132157}
133158
159+ // / Closes any currently displayed Rokt placement.
160+ // / Call this method to programmatically dismiss an active Rokt overlay or embedded placement.
134161- (void )close {
135162 dispatch_async (dispatch_get_main_queue (), ^{
136163 // Forwarding call to kits
@@ -143,6 +170,9 @@ - (void)close {
143170 });
144171}
145172
173+ // / Retrieves the attribute mapping configuration for the Rokt Kit from the mParticle dashboard settings.
174+ // / The mapping defines how attribute keys should be renamed before being sent to Rokt (e.g., "userEmail" → "email").
175+ // / @return An array of mapping dictionaries with "map" (source key) and "value" (destination key), or nil if Rokt Kit is not configured.
146176- (NSArray <NSDictionary<NSString *, NSString *> *> *)getRoktPlacementAttributesMapping {
147177 NSArray <NSDictionary <NSString *, NSString *> *> *attributeMap = nil ;
148178
@@ -190,6 +220,9 @@ - (void)close {
190220 return attributeMap;
191221}
192222
223+ // / Retrieves the configured identity type to use for hashed email from the Rokt Kit configuration.
224+ // / The hashed email identity type is determined by dashboard settings and may vary (e.g., CustomerId, Other, etc.).
225+ // / @return The NSNumber representing the MPIdentity type for hashed email, or nil if not configured.
193226- (NSNumber *)getRoktHashedEmailUserIdentityType {
194227 // Get the kit configuration
195228 NSArray <NSDictionary *> *kitConfigs = [MParticle sharedInstance ].kitContainer_PRIVATE .originalConfig .copy ;
@@ -207,6 +240,11 @@ - (NSNumber *)getRoktHashedEmailUserIdentityType {
207240 return hashedIdentityTypeNumber;
208241}
209242
243+ // / Ensures the "sandbox" attribute is present in the attributes dictionary.
244+ // / If not already set by the caller, the sandbox value is automatically determined based on the current mParticle environment
245+ // / (MPEnvironmentDevelopment → "true", production → "false"). This tells Rokt whether to show test or production ads.
246+ // / - Parameter attributes: The input attributes dictionary to validate
247+ // / @return A dictionary with the sandbox attribute guaranteed to be present
210248- (NSDictionary <NSString *, NSString *> *)confirmSandboxAttribute : (NSDictionary <NSString *, NSString *> * _Nullable)attributes {
211249 NSMutableDictionary <NSString *, NSString *> *finalAttributes = attributes.mutableCopy ;
212250
@@ -225,6 +263,13 @@ - (NSNumber *)getRoktHashedEmailUserIdentityType {
225263 return finalAttributes;
226264}
227265
266+ // / Synchronizes user identity with mParticle if email or hashed email is provided in attributes.
267+ // / If the email or hashed email in attributes differs from the current user's identity, this method performs
268+ // / an identity API call to update the user before proceeding. This ensures Rokt has the most current user identity.
269+ // / - Parameters:
270+ // / - attributes: Dictionary that may contain "email" or "emailsha256" keys
271+ // / - user: The current mParticle user
272+ // / - completion: Completion handler called with the resolved (possibly updated) user
228273- (void )confirmUser : (NSDictionary <NSString *, NSString *> * _Nullable)attributes user : (MParticleUser * _Nullable)user completion : (void (^)(MParticleUser *_Nullable))completion {
229274 NSString *email = attributes[@" email" ];
230275 NSString *hashedEmail = attributes[@" emailsha256" ];
0 commit comments