<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GroupActivities",
  "identifier" : "/documentation/GroupActivities/GroupSessionMessenger/messages(of:)-jvoz",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Group Activities",
      "GroupActivities"
    ],
    "preciseIdentifier" : "s:15GroupActivities0A16SessionMessengerC8messages2ofAC8MessagesVy_xGxm_tSeRzSERzlF"
  },
  "title" : "messages(of:)"
}
-->

# messages(of:)

Returns the asynchronous sequence of messages that match the app-specific type.

```
final func messages<Message>(of type: Message.Type) -> GroupSessionMessenger.Messages<Message> where Message : Decodable, Message : Encodable
```

## Parameters

`type`

The class of the custom type you use to package the message contents.

## Discussion

Call this method to receive the messages that other participants send to the
group. This method returns a [`GroupSessionMessenger.Messages`](/documentation/GroupActivities/GroupSessionMessenger/Messages) structure, which conforms to the
`AsyncSequence` protocol. This sequence contains all, some, or none of the
messages sent over time. You retrieve messages by iterating over them using
an asynchronous `for`-`in` loop, as shown in the following example:

```
let sessionMessenger = GroupSessionMessenger(session: groupSession)

async {
    for await move in sessionMessenger.messages(of: TicTacToe.Move.self) {
        self.board.addMove(move)
    }
}
```

---

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)