EkoMessageRepository

@interface EkoMessageRepository : NSObject

Repository provides access messages and collections.

  • The context used to create the instance.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nonnull) EkoClient *client;

    Swift

    var client: EkoClient { get }
  • Designated intializer.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithClient:(nonnull EkoClient *)client;

    Swift

    init(client: EkoClient)

    Parameters

    client

    A valid context instance.

  • Creates a new custom message (convenience method).

    Note

    Behind the scenes this methods calls NSJSONSerialization, which states that an object that may be converted to JSON must have the following properties:

    • Top level object is an NSArray or NSDictionary.

    • All objects are NSString, NSNumber, NSArray, NSDictionary, or NSNull.

    • All dictionary keys are NSStrings.

    • NSNumbers are not NaN or infinity.

    Failing to do so will result in an exception.

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createCustomMessageWithChannelId:(nonnull NSString *)channelId
                                    data:(nonnull NSDictionary<NSString *, id> *)
                                             data;

    Swift

    func createCustomMessage(withChannelId channelId: String, data: [String : Any]) -> EkoObject<EkoMessage>

    Parameters

    channelId

    The channel we want to create a message in.

    data

    Message (custom) data.

    Return Value

    The EkoMessage live object.

  • Creates a new custom message (convenience method).

    Note

    Behind the scenes this methods calls NSJSONSerialization, which states that an object that may be converted to JSON must have the following properties:

    • Top level object is an NSArray or NSDictionary.

    • All objects are NSString, NSNumber, NSArray, NSDictionary, or NSNull.

    • All dictionary keys are NSStrings.

    • NSNumbers are not NaN or infinity.

    Failing to do so will result in an exception.

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createCustomMessageWithChannelId:(nonnull NSString *)channelId
                                    data:
                                        (nonnull NSDictionary<NSString *, id> *)data
                                    tags:(nullable NSArray<NSString *> *)tags;

    Swift

    func createCustomMessage(withChannelId channelId: String, data: [String : Any], tags: [String]?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    A channel Identifier.

    data

    Message (custom) data.

    tags

    An array of tags (you can store here whatever you want).

  • Creates a new custom message (convenience method).

    Note

    Behind the scenes this methods calls NSJSONSerialization, which states that an object that may be converted to JSON must have the following properties:

    • Top level object is an NSArray or NSDictionary.

    • All objects are NSString, NSNumber, NSArray, NSDictionary, or NSNull.

    • All dictionary keys are NSStrings.

    • NSNumbers are not NaN or infinity.

    Failing to do so will result in an exception.

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createCustomMessageWithChannelId:(nonnull NSString *)channelId
                                    data:(nonnull NSString *)data
                                parentId:(nullable NSString *)parentId;

    Swift

    func createCustomMessage(withChannelId channelId: String, data: String, parentId: String?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    The channel we want to create a message in.

    data

    Message (custom) data.

    parentId

    The new message parent (note: this cannot be changed later).

    Return Value

    The EkoMessage live object.

  • Creates a new custom message.

    Note

    Behind the scenes this methods calls NSJSONSerialization, which states that an object that may be converted to JSON must have the following properties:

    • Top level object is an NSArray or NSDictionary.

    • All objects are NSString, NSNumber, NSArray, NSDictionary, or NSNull.

    • All dictionary keys are NSStrings.

    • NSNumbers are not NaN or infinity.

    Failing to do so will result in an exception.

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createCustomMessageWithChannelId:(nonnull NSString *)channelId
                                    data:
                                        (nonnull NSDictionary<NSString *, id> *)data
                                    tags:(nullable NSArray<NSString *> *)tags
                                parentId:(nullable NSString *)parentId;

    Swift

    func createCustomMessage(withChannelId channelId: String, data: [String : Any], tags: [String]?, parentId: String?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    The channel we want to create a message in.

    data

    Message (custom) data.

    tags

    An array of tags (you can store here whatever you want)

    parentId

    The new message parent (note: this cannot be changed later).

    Return Value

    The EkoMessage live object.

  • Creates a new text message (convenience method).

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createTextMessageWithChannelId:(nonnull NSString *)channelId
                                  text:(nonnull NSString *)text;

    Swift

    func createTextMessage(withChannelId channelId: String, text: String) -> EkoObject<EkoMessage>

    Parameters

    channelId

    The channel we want to create a message in.

    text

    The text message to be sent.

    Return Value

    The EkoMessage live object.

  • Creates a new text message (convenience method).

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createTextMessageWithChannelId:(nonnull NSString *)channelId
                                  text:(nonnull NSString *)text
                                  tags:(nullable NSArray<NSString *> *)tags;

    Swift

    func createTextMessage(withChannelId channelId: String, text: String, tags: [String]?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    A channel Identifier.

    text

    Message text.

    tags

    An array of tags (you can store here whatever you want).

  • Creates a new text message (convenience method).

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createTextMessageWithChannelId:(nonnull NSString *)channelId
                                  text:(nonnull NSString *)text
                              parentId:(nullable NSString *)parentId;

    Swift

    func createTextMessage(withChannelId channelId: String, text: String, parentId: String?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    The channel we want to create a message in.

    text

    The text message to be sent.

    parentId

    The new message parent (note: this cannot be changed later).

    Return Value

    The EkoMessage live object.

  • Creates a new text message.

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createTextMessageWithChannelId:(nonnull NSString *)channelId
                                  text:(nonnull NSString *)text
                                  tags:(nullable NSArray<NSString *> *)tags
                              parentId:(nullable NSString *)parentId;

    Swift

    func createTextMessage(withChannelId channelId: String, text: String, tags: [String]?, parentId: String?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    The channel we want to create a message in.

    text

    The text message to be sent.

    tags

    An array of tags (you can store here whatever you want).

    parentId

    The new message parent (note: this cannot be changed later).

    Return Value

    The EkoMessage live object.

  • Creates a new image message (convenience method).

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createImageMessageWithChannelId:(nonnull NSString *)channelId
                                  image:(nonnull UIImage *)image
                                caption:(nullable NSString *)caption
                              fullImage:(BOOL)fullImage;

    Swift

    func createImageMessage(withChannelId channelId: String, image: UIImage, caption: String?, fullImage: Bool) -> EkoObject<EkoMessage>

    Parameters

    channelId

    The channel we want to create a message in.

    image

    The UIImage to be sent (will be sent as JPG).

    caption

    The image caption.

    fullImage

    Whether or not the image should be sent at full resolution.

    Return Value

    The EkoMessage live object.

  • Creates a new image message (convenience method).

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createImageMessageWithChannelId:(nonnull NSString *)channelId
                                  image:(nonnull UIImage *)image
                                caption:(nullable NSString *)caption
                              fullImage:(BOOL)fullImage
                                   tags:(nullable NSArray<NSString *> *)tags;

    Swift

    func createImageMessage(withChannelId channelId: String, image: UIImage, caption: String?, fullImage: Bool, tags: [String]?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    A channel Identifier.

    image

    UIImage to be sent (will be sent as JPG).

    fullImage

    whether or not the image should be sent at full resolution.

    tags

    An array of tags (you can store here whatever you want).

  • Creates a new image message (convenience method).

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createImageMessageWithChannelId:(nonnull NSString *)channelId
                                  image:(nonnull UIImage *)image
                                caption:(nullable NSString *)caption
                              fullImage:(BOOL)fullImage
                               parentId:(nullable NSString *)parentId;

    Swift

    func createImageMessage(withChannelId channelId: String, image: UIImage, caption: String?, fullImage: Bool, parentId: String?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    The channel we want to create a message in.

    image

    The UIImage to be sent (will be sent as JPG).

    caption

    The image caption.

    fullImage

    Whether or not the image should be sent at full resolution.

    parentId

    The new message parent (note: this cannot be changed later).

    Return Value

    The EkoMessage live object.

  • Creates a new image message.

    Declaration

    Objective-C

    - (nonnull EkoObject<EkoMessage *> *)
        createImageMessageWithChannelId:(nonnull NSString *)channelId
                                  image:(nonnull UIImage *)image
                                caption:(nullable NSString *)caption
                              fullImage:(BOOL)fullImage
                                   tags:(nullable NSArray<NSString *> *)tags
                               parentId:(nullable NSString *)parentId;

    Swift

    func createImageMessage(withChannelId channelId: String, image: UIImage, caption: String?, fullImage: Bool, tags: [String]?, parentId: String?) -> EkoObject<EkoMessage>

    Parameters

    channelId

    A channel Identifier.

    image

    UIImage to be sent (will be sent as JPG).

    fullImage

    whether or not the image should be sent at full resolution.

    tags

    An array of tags (you can store here whatever you want).

    parentId

    The new message parent (note: this cannot be changed later).

  • Creates a new file message.

    Declaration

    Objective-C

    - (nullable EkoObject<EkoMessage *> *)
        createFileMessageWithChannelId:(nonnull NSString *)channelId
                                  data:(nonnull NSData *)data
                              filename:(nullable NSString *)filename
                                  tags:(nullable NSArray<NSString *> *)tags
                              parentId:(nullable NSString *)parentId
                            completion:(EkoRequestCompletion _Nullable)completion;

    Swift

    func createFileMessage(withChannelId channelId: String, data: Data, filename: String?, tags: [String]?, parentId: String?, completion: EkoRequestCompletion? = nil) -> EkoObject<EkoMessage>?

    Parameters

    channelId

    A channel Identifier.

    data

    File Data to be sent (will be sent as NSData).

    filename

    File name to be sent (will be sent as NSString).

    tags

    An array of tags (you can store here whatever you want).

    parentId

    The new message parent (note: this cannot be changed later).

  • @abstract Creates a collection of all messages filtered by channel id.

    @discussion When observing changes on the collection, the only time EkoCollectionChange gives back a deletion update (on messages) is when the user has been banned or has left the channel: to confirm this, you can also observe changes in the EkoChannel object (if this also gets deleted, you have either left the channel or you’ve been banned).

    @remarks Let’s say that a channel has the messages (in chronological order): ABC…XYZ

    When reverse is set to:

    • false, we will fetch the first (oldest) messages in chronological order: ABC first, then the next page etc.

    • true, we will fetch the last (newest) messages in reverse-chronological order: ZYX first, then the previous page etc.

    It’s up to the developer to call the right loadNext/loadPrevious page in the returned collection based on the reverse value:

    • loadNext loads newer messages in comparison with the last loaded page

    • loadPrevious loads older messages in comparison with the last loaded page

    Note

    when asking for more messages, based on the reverse preference, you’ll need to ask for the next page (if the reverse is false) or the previous page (if the reverse is true).

    Declaration

    Objective-C

    - (nonnull EkoCollection<EkoMessage *> *)messagesWithChannelId:
                                                 (nonnull NSString *)channelId
                                                           reverse:(BOOL)reverse;

    Swift

    func messages(withChannelId channelId: String, reverse: Bool) -> EkoCollection<EkoMessage>

    Parameters

    channelId

    The Channel of which messages we are interested in.

    reverse

    Whether we’d like the collection in chronological order or not.

    Return Value

    The messages collection.

  • Creates and returns a collection of all messages filtered by the given channelId, and tags (convenience method).

    Note

    A message is matched when it contains ANY tag listed in includingTags, and contains NONE of the tags listed in excludingTags.

    Declaration

    Objective-C

    - (nonnull EkoCollection<EkoMessage *> *)
        messagesWithChannelId:(nonnull NSString *)channelId
                includingTags:(nonnull NSArray<NSString *> *)includingTags
                excludingTags:(nonnull NSArray<NSString *> *)excludingTags
                      reverse:(BOOL)reverse;

    Swift

    func messages(withChannelId channelId: String, includingTags: [String], excludingTags: [String], reverse: Bool) -> EkoCollection<EkoMessage>

    Parameters

    channelId

    The channel identifier of the channel we’re interested in

    includingTags

    The list of required message tags, pass an empty array to ignore this requirement.

    excludingTags

    The list of tags required not to be set in the messages, pass an empty array to ignore this requirement.

    Return Value

    The EkoMessage live collection.

  • Creates and returns a collection of all messages filtered by the given channelId, and parentId (convenience method).

    Declaration

    Objective-C

    - (nonnull EkoCollection<EkoMessage *> *)
        messagesWithChannelId:(nonnull NSString *)channelId
             filterByParentId:(BOOL)filterByParentId
                     parentId:(nullable NSString *)parentId
                      reverse:(BOOL)reverse;

    Swift

    func messages(withChannelId channelId: String, filterByParentId: Bool, parentId: String?, reverse: Bool) -> EkoCollection<EkoMessage>

    Parameters

    channelId

    The channel identifier of the channel we’re interested in

    filterByParentId

    Whether we’re initerested in filtering by parentId or not.

    parentId

    The messageId of the parent whose child we’re interested in.

    Return Value

    The EkoMessage live collection.

  • Creates and returns a collection of all messages filtered by the given channelId, tags, and parentId.

    Note

    A message is matched when it contains ANY tag listed in includingTags, and contains NONE of the tags listed in excludingTags.

    Declaration

    Objective-C

    - (nonnull EkoCollection<EkoMessage *> *)
        messagesWithChannelId:(nonnull NSString *)channelId
                includingTags:(nonnull NSArray<NSString *> *)includingTags
                excludingTags:(nonnull NSArray<NSString *> *)excludingTags
             filterByParentId:(BOOL)filterByParentId
                     parentId:(nullable NSString *)parentId
                      reverse:(BOOL)reverse;

    Swift

    func messages(withChannelId channelId: String, includingTags: [String], excludingTags: [String], filterByParentId: Bool, parentId: String?, reverse: Bool) -> EkoCollection<EkoMessage>

    Parameters

    channelId

    The channel identifier of the channel we’re interested in

    includingTags

    The list of required message tags, pass an empty array to ignore this requirement.

    excludingTags

    The list of tags required not to be set in the messages, pass an empty array to ignore this requirement.

    filterByParentId

    Whether we’re initerested in filtering by parentId or not.

    parentId

    The messageId of the parent whose child we’re interested in.

    reverse

    Whether we’d like the collection in chronological order or not.

    Return Value

    The EkoMessage live collection.

  • Get all of the reactions on the specific message.

    Declaration

    Objective-C

    - (nonnull EkoCollection<EkoMessageReaction *> *)
        allMessageReactionsWithMessageId:(nonnull NSString *)messageId;

    Swift

    func allMessageReactions(withMessageId messageId: String) -> EkoCollection<EkoMessageReaction>

    Parameters

    messageId

    The related message id to be observed.

    Return Value

    The EkoMessageReaction live collection.

  • Sets the tags for the given message.

    As long as the user is a member of a channel, the user can set the tags to any message of that channel.

    Declaration

    Objective-C

    - (void)setTagsForMessage:(nonnull NSString *)messageId
                         tags:(nullable NSArray<NSString *> *)tags
                   completion:(nullable EkoRequestCompletion)completion;

    Swift

    func setTagsForMessage(_ messageId: String, tags: [String]?, completion: EkoRequestCompletion? = nil)

    Parameters

    messageId

    A valid Message Id

    tags

    An array of tags

  • Gets an existing message by message Id

    Declaration

    Objective-C

    - (EkoObject<EkoMessage *> *_Nullable)getMessage:(nonnull NSString *)messageId;

    Swift

    func getMessage(_ messageId: String) -> EkoObject<EkoMessage>?
  • Unavailable

    Block call of init and new because this object cannot be created directly

    Declaration

    Objective-C

    - (nonnull instancetype)init;