Truvideo Core SDK
This Plugin demonstrates the integration of the TruvideoCoreSdk for authentication and platform-specific functionality. It includes features such as authentication, authentication status checking, and clearing authentication.
Supported Platforms
- ✅ Android
- ✅ iOS
Features
- Authenticates using API Key and Secret Key
- Checks authentication status
- Clears authentication
Requirements
- API Key & Secret Key: Required for authentication
- TruvideoCoreSdk Plugin: Must be properly installed and configured in your Flutter project
Setup
- Add TruvideoCoreSdk Plugin to your project.
- Install dependencies using:
flutter pub get - Replace the placeholders with actual API keys:
final String apiKey = "YOUR_API_KEY"; // Replace with your API Key final String secretKey = "YOUR_SECRET_KEY"; // Replace with your Secret Key - Run the app:
flutter run
Authentication Process
- Generates a payload for authentication
- Uses SHA256 HMAC to sign the payload
- Authenticates using
TruvideoCoreSdk.authenticate() - Initializes authentication with
TruvideoCoreSdk.initAuthentication() - Updates authentication status
Code Overview
Ckeck Authentication Status
isAuthenticated()
- Returns true or false indicating whether the client is authenticated. Please note that authentication may be expired.
isAuthenticationExpired()
- Return true or false indicating whether the authentication is expired. If the client is not authenticated, it always returns false.
Future<(bool, bool)> checkAuthenticationStatus() async{
bool isAuthenticated = await TruvideoCoreSdk.isAuthenticated();
bool isAuthExpired = await TruvideoCoreSdk.isAuthenticationExpired();
return (isAuthenticated, isAuthExpired);
}
Authentication process
Future<void> authenticate() async {
try {
bool isAuthenticated = await TruvideoCoreSdk.isAuthenticated();
bool isAuthExpired = await TruvideoCoreSdk.isAuthenticationExpired();
String payload = await TruvideoCoreSdk.generatePayload();
String signature = toSha256String(secret: secretKey, payload: payload) ?? '';
// Authenticate with generated payload and signature
if (!isAuthenticated || isAuthExpired ) {
await TruvideoCoreSdk.authenticate(
apiKey: apiKey,
signature: signature,
payload: payload,
externalId: "",
);
}
await TruvideoCoreSdk.initAuthentication();
} catch (e) {
print('Authentication failed: $e');
}
}
Clear Authentication
- To delete the current session and erase all associated authentication data, utilize the clearAuthentication method
Future<void> clearAuthentication() async {
await TruvideoCoreSdk.clearAuthentication();
}
License
MIT
Support
If you have any questions or suggestions regarding the SDK, please contact us at [email protected].