RCSService
A class that provides an interface for performing RCS operations.
Declaration
final class RCSServiceMentioned in
Overview
Use the TelephonyMessagingSession property rcsService to get an instance of this class.
An RCSService sends and receives different kinds of messages, distinguished by the content property of RCSMessage:
- RCSMessage.Text
Plain text.
- RCSMessage.FileTransfer
Incoming or outgoing file transfer. To send a file to a receipient, call the upload(_:): method, then send a message of this type. To receive a file, handle the incoming message from the incomingMessageNotifications asynchronous sequence, and use its metadata to call download(_:).
- RCSMessage.GeolocationPush
The sender’s location, as indicated by a latitude and longitude pair.
- RCSMessage.ComposingIndicator
An indicator that the sender is currently composing a message. Use this content type to provide “is typing” indicators to recipients.
- RCSMessage.DispositionNotification
An update regarding the processing of a message by the recipient app. This includes things like whether delivery suceeded or failed, and whether the app displayed the message to the recipient.
Use the various overloads of sendMessage(_:to:using:messageID) to send messages of these types to recipients. The following example shows how to send a plain text message with sendMessage(_:to:using:messageID:):
let service = TelephonyMessagingSession.shared.rcsService
let cellularServices = try TelephonyMessagingSession.shared.cellularServices
let cellularServiceID = cellularServices[0].id
guard service.isViable(for: cellularServiceID) else { return }
let message = RCSMessage.Text("Hello there.")
guard let handle = RCSHandle.phoneNumber(SAMPLE_PHONE_NUMBER) else { return }
try await service.sendMessage(message,
to: handle,
using:cellularServiceID,
messageID: RCSMessageID(rawValue: SAMPLE_RCS_MESSAGE_ID))To receive messages, iterate over the incomingMessageNotifications asynchronous sequence with a for-await-in loop, then handle each notification based on its message content type, like this:
let service = TelephonyMessagingSession.shared.rcsService
let incomingMessageNotifications = try service.incomingMessageNotifications
Task {
for await notification in incomingMessageNotifications {
let receivedMessage = notification.message
switch receivedMessage.content {
case .text(let text): // ...
case .fileTransfer(let fileTransfer): // ...
case .geolocationPush(let geolocationPush): // ...
case .dispositionNotification(let dispositionNotification): // ...
case .composingIndicator(let composingIndicator): // ...
}
}
}Topics
Determining service viabililty
Managing RCS configuration
Sending messages
sendMessage(_:to:using:messageID:)RCSMessage.TextsendMessage(_:to:using:messageID:)RCSMessage.FileTransfersendMessage(_:to:using:messageID:)RCSMessage.ComposingIndicatorsendMessage(_:to:using:messageID:)RCSMessage.GeolocationPushsendMessage(_:to:using:messageID:group:)RCSMessage.DispositionNotificationRCSHandleCellularServiceIDRCSMessageID
Sending encrypted messages
sendEncryptedMessageRequest(_:)RCSService.SendEncryptedMessageRequestRCSService.SendEncryptedMessageRequest.Result
Receiving messages
Revoking messages
Transferring files
upload(_:)RCSService.FileUploadRequestRCSService.FileUploadRequest.Metadatadownload(_:)RCSService.FileDownloadRequestRCSService.FileDownloadRequest.Metadata
Receiving handle updates
Reporting spam
Managing group chats
createGroupChat(_:)RCSService.CreateGroupChatRequestleaveGroupChat(_:)RCSService.LeaveGroupChatRequestaddGroupChatParticipants(_:)RCSService.AddGroupChatParticipantsRequestremoveGroupChatParticipants(_:)RCSService.RemoveGroupChatParticipantsRequestchangeGroupChatSubject(_:)RCSService.ChangeGroupChatSubjectRequestgroupChatEventsRCSService.GroupChatEvent
Discovering remote capabilities
Responding to business suggestions
Retrieving business information
Handling errors
Supporting types
RCSService.GroupChatEndedEventRCSService.GroupChatParticipantsAddedEventRCSService.GroupChatParticipantsRemovedEventRCSService.GroupChatStartedEventRCSService.GroupChatSubjectUpdatedEvent