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 ) -> MoEngageFetchRecommendationsTaskParameters
recommendationIdID of the recommendation campaign, defined on the dashboard. Required — a blank value rejects with
.invalidRequest.itemIdAnchor product ID, defined on the dashboard. Optional; ignored if empty (the server does the same).
includedFieldsProduct fields to return, defined on the dashboard. Optional; ignored if empty (the server returns its default field set).
workspaceIdThe workspace/app ID; pass
nilfor the default instance.Return Value
A task that resolves with
MoEngageRecommendedItemson success or rejects with aMoEngageRecommendationsRequestFailureReason(or a sharedMoEngageRequestFailureReasoncode) 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, usefetchRecommendations(recommendationId:itemId:includedFields:workspaceId:)which acceptsSet<String>directly.Declaration
Swift
@discardableResult @objc(fetchRecommendationsWithRecommendationId:itemId:includedFields:workspaceId:) public func fetchRecommendationsObjC( recommendationId: String, itemId: String = "", includedFields: [String] = [], workspaceId: String? = nil ) -> MoEngageFetchRecommendationsTask