Support

How do I send a message?

In order to send a message, you must first have an authenticated Layer application. After authenticating, it is only a few lines of code to send a message.

// Creates and returns a new conversation object with a single participant represented by your backend's user identifier for the participant

LYRConversation *conversation = [LYRClient newConversationWithParticipants:[NSSet setWithArray:@[@"USER-IDENTIFIER"]]];
LYRMessagePart *part = [LYRMessagePart messagePartWithText:@"Hi, how are you?"];

// Creates and returns a new message object with the given conversation and array of message parts
LYRMessage *message = [self.layerClient newMessageWithParts:@[part] options:nil error:nil];

// Sends the specified message
[conversation sendMessage:message error:&error];
Have more questions? Submit a request