Introduction
Welcome to the documentation for StreamChat-XCFramework. This documentation will provide you with detailed information on how to use and integrate the StreamChat framework into your iOS applications.
Getting Started
To get started with StreamChat-XCFramework, follow the steps below:
- Install the StreamChat framework by using one of the following methods:
- Using Cocoapods: Add ‘StreamChat’ to your Podfile and run pod install.
- Using Swift Package Manager: Add ‘https://github.com/GetStream/stream-chat-swift’ as a Swift Package in Xcode.
- Import the framework in your code by adding the following import statement:
- Initialize a StreamChat client object with your API key and configure it:
- Authenticate the client with a user token or using JWT:
import StreamChat
// Create a configuration object
let config = ChatClientConfig(apiKey: "YOUR_API_KEY")
// Create a client
let client = ChatClient(config: config)
// Authenticate using a user token
client.connectUser(token: "USER_TOKEN") { result in
// Handle the result
}
// Authenticate using JWT
client.set(user: User(id: "USER_ID"), token: "USER_JWT_TOKEN") { result in
// Handle the result
}
Usage
StreamChat-XCFramework provides various functionalities to enable real-time chat in your application. Below are some common use cases:
Use Case 1: Sending a Message
To send a message, use the following code:
let message = Message(text: "Hello, World!")
channel.send(message: message) { result in
// Handle the result
}
Use Case 2: Retrieving Channel Messages
To retrieve channel messages, use the following code:
channel.queryMessages { result in
switch result {
case .success(let messages):
// Handle the retrieved messages
case .failure(let error):
// Handle the error
}
}
More Examples
For more examples and detailed information on StreamChat-XCFramework, please refer to the official GitHub repository.
Conclusion
Congratulations! You have successfully installed and integrated StreamChat-XCFramework into your iOS application. Now you can build powerful chat functionality using StreamChat. Explore the documentation for more details and advanced features.