Client APIs

You can use the CMPComapi client instance obtained during initialisation to access SDK APIs.

Session

Get the current profileID:

NSString *profileID = [client profileID];
let profileId = client.profileID

Check if session is successfully created:

BOOL isSuccessfullyCreated = [client isSessionSuccessfullyCreated];
let isSessionSuccesfullyCreated = client.isSessionSuccessfullyCreated

Services

To access services, you must call methods from the proper group:

client.services.profile
client.services.session
client.services.messaging
client.services.profile
client.services.session
client.services.messaging

Most services use the CMPResult object as a return value in completion blocks:

@interface CMPResult<__covariant T> : NSObject

@property (nonatomic, nullable) T object;
@property (nonatomic, nullable) NSError *error;
@property (nonatomic, nullable) NSString *eTag;
@property (nonatomic) NSInteger code;

- (instancetype)init NS_UNAVAILABLE;

- (instancetype)initWithObject:(nullable T)object error:(nullable NSError *)error eTag:(nullable NSString *)eTag code:(NSInteger)code;

@end
open class Result<T> : NSObject where T : AnyObject {

    open var object: T?
    open var error: Error?
    open var eTag: String?
    open var code: Int

    public init(object: T?, error: Error?, eTag: String?, code: Int)
}

You can get the ETag value from this, as well as an HTTP status code and potential error.