incomingMessageNotifications
An asynchronous sequence of incoming message notifications produced by this service.
Declaration
final var incomingMessageNotifications: some AsyncSequence<RCSService.IncomingMessageNotification, Never> { get throws }Discussion
Iterate over this sequence with a for-await-in loop to receive RCSService.IncomingMessageNotification instances that indicate the arrival of incoming messages, 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): // ...
}
}For each message type, the matched case contains an instance of the relevant RCSMessage.Content type as its associated value. In this example, text would contain string content in its body property, and geolocationPush would have geolocation values in its latitude and longitude properties.