<!--
{
  "availability" : [
    "iOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "TelephonyMessagingKit",
  "identifier" : "/documentation/TelephonyMessagingKit/SMSService",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "TelephonyMessagingKit"
    ],
    "preciseIdentifier" : "s:21TelephonyMessagingKit10SMSServiceC"
  },
  "title" : "SMSService"
}
-->

# SMSService

A class that provides an interface for performing SMS operations.

```
final class SMSService
```

## Overview

Use the [`TelephonyMessagingSession`](/documentation/TelephonyMessagingKit/TelephonyMessagingSession) property [`smsService`](/documentation/TelephonyMessagingKit/TelephonyMessagingSession/smsService) to get an instance of this class.
You can then monitor the [`incomingMessageNotifications`](/documentation/TelephonyMessagingKit/SMSService/incomingMessageNotifications) asynchronous sequence to receive notifications of incoming messages, and the [`sendMessage(_:)`](/documentation/TelephonyMessagingKit/SMSService/sendMessage(_:)) method to send outgoing messages.

The following example shows how to send an SMS message with the first service found in the session’s [`cellularServices`](/documentation/TelephonyMessagingKit/TelephonyMessagingSession/cellularServices) array.

```swift
import TelephonyMessagingKit

let service = TelephonyMessagingSession.shared.smsService

let cellularServices = try session.cellularServices
let cellularServiceID = cellularServices[0].id

guard service.isViable(for: cellularServiceID) else { return }

let message = SMSMessage(
    cellularServiceID: cellularServiceID,
    handle: SMSHandle(phoneNumber: SAMPLE_PHONE_NUMBER),
    messageID: SMSMessageID(rawValue: SAMPLE_MESSAGE_ID),
    content: SMSContent(body: "Hello there.")
)

try await service.sendMessage(message)
```

To receive messages, iterate over the [`incomingMessageNotifications`](/documentation/TelephonyMessagingKit/SMSService/incomingMessageNotifications) asynchronous sequence, and retrieve messages from each notification as it arrives, as shown below:

```swift
import TelephonyMessagingKit

let service = TelephonyMessagingSession.shared.smsService

let incomingMessageNotifications = try service.incomingMessageNotifications
Task {
    for await notification in incomingMessageNotifications {
        let receivedMessage = notification.message
        // Process receivedMessage.
    }
}
```

## Topics

### Determining service viabililty

[`func isViable(for: CellularServiceID) -> Bool`](/documentation/TelephonyMessagingKit/SMSService/isViable(for:))

Queries whether the device can perform SMS operations at this time.

[`var viabilityNotifications: some AsyncSequence<SMSService.ViabilityNotification, Never>`](/documentation/TelephonyMessagingKit/SMSService/viabilityNotifications)

An asynchronous sequence of service viability notifications produced by this service.

[`struct ViabilityNotification`](/documentation/TelephonyMessagingKit/SMSService/ViabilityNotification)

A notification that indicates whether SMS is viable for a given cellular service.

### Sending messages

[`func sendMessage(SMSMessage) async throws`](/documentation/TelephonyMessagingKit/SMSService/sendMessage(_:))

Sends an SMS message to the given destination.

[`struct SMSMessage`](/documentation/TelephonyMessagingKit/SMSMessage)

A structure that contains the data of an SMS message.

### Receiving messages

[`var incomingMessageNotifications: some AsyncSequence<SMSService.IncomingMessageNotification, Never>`](/documentation/TelephonyMessagingKit/SMSService/incomingMessageNotifications)

An asynchronous sequence of incoming message notifications produced by this service.

[`struct IncomingMessageNotification`](/documentation/TelephonyMessagingKit/SMSService/IncomingMessageNotification)

A structure that contains information about an incoming SMS message.

### Handling critical state changes

[`var criticalMessageStateNotifications: some AsyncSequence<SMSService.CriticalMessageStateNotification, Never>`](/documentation/TelephonyMessagingKit/SMSService/criticalMessageStateNotifications)

An asynchronous sequence of critical message state notifications.

[`struct CriticalMessageStateNotification`](/documentation/TelephonyMessagingKit/SMSService/CriticalMessageStateNotification)

A structure that contains information about a critical SMS message.

### Reporting spam

[`func reportSpam(SMSMessage) async throws`](/documentation/TelephonyMessagingKit/SMSService/reportSpam(_:))

Reports an SMS message as spam to the carrier and to partners.

### Handling errors

[`enum Error`](/documentation/TelephonyMessagingKit/SMSService/Error)

A type to define errors that can occur when performing SMS operations.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)