MoEngageSDKRecommendations

@objc(MoEngageSDKRecommendations)
public final class MoEngageSDKRecommendations : NSObject, @unchecked Sendable

Public entry point for the Recommendations module.

A thin dispatch adapter — all guard/cache/network logic lives in MoEngageRecommendations/fetch(recommendationId:itemId:includedFields:task:forInstance:). This type’s only job is to get onto the correct MoEngageSDKInstance actor safely and hand off.

  • Fetches the recommended items for a recommendation id.

    Serves from the local cache when an unexpired entry exists for the resolved combination of recommendationId + itemId + includedFields; otherwise fetches from the server and caches the result — including an empty result, which is a valid “no recommendations available” answer.

    Declaration

    Swift

    @discardableResult
    public func fetchRecommendations(
        recommendationId: String,
        itemId: String = "",
        includedFields: Set<String> = [],
        workspaceId: String? = nil
    ) -> MoEngageFetchRecommendationsTask

    Parameters

    recommendationId

    ID of the recommendation campaign, defined on the dashboard. Required — a blank value rejects with .invalidRequest.

    itemId

    Anchor product ID, defined on the dashboard. Optional; ignored if empty (the server does the same).

    includedFields

    Product fields to return, defined on the dashboard. Optional; ignored if empty (the server returns its default field set).

    workspaceId

    The workspace/app ID; pass nil for the default instance.

    Return Value

    A task that resolves with MoEngageRecommendedItems on success or rejects with a MoEngageRecommendationsRequestFailureReason (or a shared MoEngageRequestFailureReason code) on failure.

  • Objective-C compatible overload for fetchRecommendations(recommendationId:itemId:includedFields:workspaceId:). Accepts anNSArray(bridged as[String]) and converts toSet` internally.

    Note

    For Swift code, use fetchRecommendations(recommendationId:itemId:includedFields:workspaceId:) which accepts Set<String> directly.

    Declaration

    Swift

    @discardableResult
    @objc(fetchRecommendationsWithRecommendationId:itemId:includedFields:workspaceId:)
    public func fetchRecommendationsObjC(
        recommendationId: String,
        itemId: String = "",
        includedFields: [String] = [],
        workspaceId: String? = nil
    ) -> MoEngageFetchRecommendationsTask