Ruut Flutter SDK
Ruut Flutter SDK provides developers with a seamless way to integrate the Ruut chat widget into their Flutter applications.
Installation
To use the Ruut Flutter SDK in your Flutter project, add ruut
as a dependency in your pubspec.yaml
file:
dependencies:
flutter:
sdk: flutter
ruut: ^1.0.0
Permissions
Add the following permissions to your app's manifest files: Android Add these lines to your android/app/src/main/AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Also, add the following attribute to your application tag:
<application
android:usesCleartextTraffic="true"
iOS
Add the following keys to your ios/Runner/Info.plist
file:
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library for image uploads.</string>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera for image captures.</string>
Usage
import 'package:flutter/material.dart';
import 'package:ruut/ruut.dart';
class MyRuutScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Ruut(
ruutToken: 'YOUR_RUUT_TOKEN',
user: RuutUser(
id: 'USER_ID',
email: 'user@example.com',
fullName: 'John Doe',
// Add other user details here
),
onReady: () {
print('Ruut is ready');
},
);
}
}
Features
Setting User Details
Ruut.setUser(RuutUser(
id: 'USER_ID',
email: 'user@example.com',
fullName: 'John Doe',
// Add other user details here
));
Custom Attributes
Set custom attributes for the user:
Ruut.setCustomAttributes({'plan': 'Premium', 'tier': 'Tier 2'});
));
Resetting User
To reset the user data:
Ruut.resetUser();
Deleting Custom Attributes
To delete a specific custom attribute:
Ruut.deleteCustomAttribute('customAttributeKey');
RuutUser Model
The RuutUser model includes the following properties:
- id (required): The user's unique identifier
- email: User's email address
- avatarUrl: URL to the user's avatar image
- fullName: User's full name
- phone: User's phone number
- identifierHash: Identifier hash for the user
- description: A brief description of the user
- countryCode: Two-letter country code
- city: User's city
- companyName: User's company name
- socialProfiles: Social profile information (Twitter, Facebook, GitHub, LinkedIn)
Troubleshooting
If you encounter any issues, please ensure that:
- All required permissions are added to your app's manifest files.
- Your Ruut token is correct and valid.
- You have a stable internet connection.
For more detailed information or support, please visit our documentation or contact our support team.
License
This project is licensed under the MIT License - see the LICENSE file for details.