MoEngageBaseTask
@objc(MoEngageBaseTask)
open class MoEngageBaseTask : NSObject, @unchecked Sendable
Base class for the per-API typed tasks returned by public SDK APIs.
Exposes an ObjC-bridgeable Any-typed onSuccess / onFailure surface; Swift
consumers get the typed equivalents through MoEngageTaskProtocol on each subclass.
- Handlers are single-slot (last-writer-wins) and always dispatched on the main thread.
- Late-attach replays the cached outcome immediately when a handler is attached after
resolve/rejecthas already fired. cancel()clears pending handlers; the underlying SDK operation continues to natural completion and its result is discarded.
-
Register a handler invoked on the main thread when the operation succeeds. Single-slot: a second call replaces the previous handler. Returns
selfso ObjC consumers can chain.Declaration
Swift
@discardableResult @objc public func onSuccess(_ handler: @MainActor @escaping (Any) -> Void) -> MoEngageBaseTask -
Register a handler invoked on the main thread when the operation fails. Single-slot: a second call replaces the previous handler. Returns
selfso ObjC consumers can chain.Declaration
Swift
@discardableResult @objc public func onFailure( _ handler: @MainActor(unsafe) @escaping (MoEngageRequestFailure) -> Void ) -> MoEngageBaseTask -
Cancel any pending handlers. The underlying operation is not aborted; its result is discarded. An awaiting
result()consumer throws instead of hanging.Declaration
Swift
@objc public func cancel()