Suggestions

close search

Messages

Once authenticed, users can send or received messages such as: text, photo, video, audio, location, contact...

1. Create a message

You can create a message by constructors. Example:

    // Text message
    StringeeMessage *textMsg = [[StringeeTextMessage alloc] initWithText:@"Hello" metadata:nil];

    // Location message
    StringeeMessage *locationMsg = [[StringeeLocationMessage alloc] initWithlatitude:latitude longitude:longitude metadata:nil];

    // Photo message from PickerController
    UIImage *image = (UIImage *)info[UIImagePickerControllerOriginalImage];
    StringeeMessage *photoMsg = [[StringeePhotoMessage alloc] initWithImage: metadata:nil];

2. Send a message

Send a Message by calling:

    NSError *error;
    [conversation sendMessage:msg error:&error];

3. Get Messages

Messages are stored on Stringee server and cached on Local Database as well. You can get messages as follows:

3.1. Get local messages

To get local messages of a conversation which are saved in the local database, you call:

    [conversation getLocalMessagesWithCount:25 completionHandler:^(BOOL status, int code, NSString *message, id data) {

    }];

In which:

3.2. Get last messages

To get latest messages from Stringee server, you call:

    [conversation getLastMessagesWithCount:25 completionHandler:^(BOOL status, int code, NSString *message, id data) {

    }];

In which:

3.3. Get messages after

To get a list of messages tied to a conversation from server which have sequence greater than seq, you call:

    [conversation getMessagesAfter:sequence withCount:25 completionHandler:^(BOOL status, int code, NSString *message, id data) {

    }];

In which:

3.4. Get messages before

To get a list of messages tied to a conversation from server which have sequence smaller than seq, you call:

    [conversation getMessagesBefore:sequence withCount:25 completionHandler:^(BOOL status, int code, NSString *message, id data) {

    }];

In which:

4. Message statuses

Stringee keeps track of the recipient status of each message. There are five possible statuses: Pending, Sending, Sent, Delivered, Read. Stringee automatically updates the recipient status to sent, delivered. The only update your app can perform is to mark a conversation's messages as read:

    [conversation markAllMessagesAsSeenWithCompletionHandler:^(BOOL status, int code, NSString *message) {

    }];

Stringee will notify you of the status update of a message via the onObjectChange event of StringeeClient.

5. Delete message

To delete a message, you call:

    [message deleteWithCompletionHandler:^(BOOL status, int code, NSString *message) {
        NSLog(@"deleteMessage %@", message);
    }];

6. Pin message

In order to pin a message, you call:

    [conversation pinMessage:msg isPin:true completion:^(BOOL status, int code, NSString *message) {
        NSLog(@"pinMessage %@", message);
    }];

In which:

7. Edit message

In order to edit a message, you call:

    [conversation editMessage:msg newContent:newContent completion:^(BOOL status, int code, NSString *message) {
        NSLog(@"editMessage %@", message);
    }];

Note: You can only edit text message.

In which:

8. Revoke message

In order to revoke a message, you call:

    [conversation revokeMessage:msg completion:^(BOOL status, int code, NSString *message) {
        NSLog(@"revokeMessage %@", message);
    }];

In which: