EMMobileMessageManager
@interface EMMobileMessageManager : NSObject
The manager provides way to create outgoing messages for the server and send/fetch messages to/from the server.
Since
5.3-
Fetch a message from the server. This method fetches the first message from server queue.
Declaration
Objective-C
- (void)fetchMessageWithTimeout:(NSTimeInterval)timeout customHeaders: (nullable NSDictionary<NSString *, NSString *> *)headers completionHandler: (nonnull void (^)(EMFetchMessageResponse *_Nullable, NSError *_Nullable))completionHandler;
Swift
func fetchMessage(timeout: TimeInterval, customHeaders headers: [String : String]?, completionHandler: @escaping (EMFetchMessageResponse?, Error?) -> Void)
Parameters
timeout
Maximum time in second to wait for an incoming message.
headers
The request parameter containing custom header.
completionHandler
The block to invoke on the main thread upon completion which contains the response and error information if any.
-
Fetch a message from the server. This method fetches the first message from server queue.
Declaration
Objective-C
- (void)fetchMessageWithMessageId:(nonnull NSString *)messageId customHeaders: (nullable NSDictionary<NSString *, NSString *> *)headers completionHandler: (nonnull void (^)(EMFetchMessageResponse *_Nullable, NSError *_Nullable))completionHandler;
Swift
func fetchMessage(messageId: String, customHeaders headers: [String : String]?, completionHandler: @escaping (EMFetchMessageResponse?, Error?) -> Void)
Parameters
messageId
Identifier of the message to fetch.
headers
The request parameter containing custom header.
completionHandler
The block to invoke on the main thread upon completion which contains the response and error information if any.
-
Sends a message acknowledgment to the server.
Declaration
Objective-C
- (void)acknowledgeMessage:(nonnull EMIncomingMessage *)incomingMessage customHeaders: (nullable NSDictionary<NSString *, NSString *> *)headers completionHandler: (nonnull void (^)(BOOL, NSError *_Nullable))completionHandler;
Swift
func acknowledge(message incomingMessage: EMIncomingMessage, customHeaders headers: [String : String]?, completionHandler: @escaping (Bool, Error?) -> Void)
Parameters
incomingMessage
The incoming message to acknowledge.
headers
The request parameter containing custom header.
completionHandler
The block to invoke on the main thread upon completion which contains the response and error information if any.
-
Sends a message to the server.
Declaration
Objective-C
- (void)sendMessage:(nonnull EMOutgoingMessage *)outgoingMessage customHeaders:(nullable NSDictionary<NSString *, NSString *> *)headers completionHandler:(nonnull void (^)(EMSendMessageResponse *_Nullable, NSError *_Nullable))completionHandler;
Swift
func send(message outgoingMessage: EMOutgoingMessage, customHeaders headers: [String : String]?, completionHandler: @escaping (EMSendMessageResponse?, Error?) -> Void)
Parameters
outgoingMessage
The message to send.
headers
The request parameter containing custom header.
completionHandler
The block to invoke on the main thread upon completion which contains the response and error information if any.
-
Creates a generic message that can be sent to the OOB server.
Declaration
Objective-C
- (nonnull EMOutgoingMessage *) createGenericOutgoingMessageWithContentType:(nonnull NSString *)contentType content:(nonnull NSData *)content;
Swift
func createGenericOutgoingMessage(contentType: String, content: Data) -> EMOutgoingMessage
Parameters
contentType
Message content-type.
content
Message content.
Return Value
The generic message ready to be sent.