MTE Relay Client for Flutter (CocoaPods)
Introduction
This Flutter plugin provides the Eclypses MteRelay Mobile Client for iOS and Android. It enables secure, encrypted HTTP(S) communication between your Flutter app and your backend via an MteRelay server. You must have licensed access to an MteRelay server instance. More Info
Purpose of MteRelay:
- Securely relay HTTP requests to your server
- Protect sensitive headers and data with MTE encryption
- Stream large files efficiently
This guide provides a quick-start for experienced developers. For detailed examples, troubleshooting, and in-depth explanations, see the complete documentation on GitHub.
Prerequisites
- Flutter SDK (stable channel)
- iOS 16.0+ / Android SDK
- CocoaPods (for iOS)
- Access to a licensed MteRelay server instance
Installation
Add to your pubspec.yaml:
dependencies:
mte_relay_client_plugin:
git:
url: https://github.com/Eclypses/mte-relay-client-flutter-pod.git
ref: 4.3.1
Run flutter pub get.
iOS Setup (CocoaPods)
Update your ios/Podfile:
platform :ios, '16.0'
target 'Runner' do
use_frameworks!
pod 'MteRelay', :git => 'https://github.com/Eclypses/mte-relay-client-ios.git', :tag => '4.4.7'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
Then run:
cd ios && pod install --repo-update && cd ..
Android Setup
No additional configuration required.
Setup
Import and initialize the plugin:
import 'package:mte_relay_client_plugin/mte_relay_client_plugin.dart';
import 'package:mte_relay_client_plugin/mte_relay_response_model.dart';
class YourClass {
final _relay = MteRelayClientPlugin();
Future<void> init() async {
// Set up callbacks
_relay.relayResponseStream.listen((message) {
// Handle relay messages
});
_relay.relayStreamResponseStream.listen((args) {
// Handle file stream responses
bool success = args['success'];
int statusCode = args['statusCode'];
Uint8List? data = args['data'];
});
// Initialize relay
await _relay.initializeRelay();
}
}
Usage
Standard HTTP Request
final args = {
'url': 'https://your-relay-server.com',
'route': '/api/endpoint', // Encrypted
'method': 'POST',
'headers': {'Content-Type': 'application/json'},
'headersToEncrypt': ['Content-Type'],
'pathnamePrefix': null, // Optional unencrypted prefix
'body': jsonEncode({'key': 'value'}),
};
Map response = await _relay.relayDataTask(args);
final result = Result.fromMap(response);
if (result.isSuccess) {
final json = result.bodyAsJsonObject;
}
Streamed File Upload
// Set up chunk streaming callback
_relay.relayRequestChunksStream.listen((streamID) async {
final fileStream = file.openRead();
await for (final chunk in fileStream) {
await _relay.sendChunk({'streamID': streamID, 'data': Uint8List.fromList(chunk)});
}
await _relay.closeStream({'streamID': streamID});
});
// Progress callback
_relay.relayStreamCompletionStream.listen((progress) {
double percent = double.parse(progress);
});
// Start upload
final args = {
'url': relayServerUrl,
'route': '/api/upload',
'method': 'POST',
'headers': {'Content-Type': 'multipart/form-data; boundary=...', 'Content-Length': '...'},
'headersToEncrypt': ['Content-Type'],
};
await _relay.relayUploadFile(args);
Streamed File Download
final args = {
'url': relayServerUrl,
'route': '/api/download/filename.pdf',
'method': 'GET',
'headers': {'Content-Type': 'application/json'},
'headersToEncrypt': ['Content-Type'],
'downloadLocation': '/path/to/save/file.pdf',
};
await _relay.relayDownloadFile(args);
// Response via relayStreamResponseStream
Re-pair with Server
await _relay.rePair({'url': relayServerUrl, 'pathnamePrefix': null});
Adjust Relay Settings
await _relay.adjustRelaySettings({
'url': relayServerUrl,
'pathnamePrefix': null,
'streamChunkSize': 1024 * 1024, // 1MB
'pairPoolSize': 3,
'persistPairs': false,
});
Logging
await _relay.enableFileLogging({'url': relayServerUrl, 'isEnabled': true});
String logs = await _relay.readLogFile({'url': relayServerUrl});
await _relay.clearLogFile({'url': relayServerUrl});
API Reference
See the source code and inline documentation for full API details. Key classes:
MteRelayClientPlugin: Main entry point for secure requests and file streamingResult<T>: Response wrapper with typed dataNativeHttpResponse: Response wrapper with rawUint8Listbody
Support
Email: info@eclypses.com
Web: www.eclypses.com
Additional Resources
- GitHub Repository – Source code and comprehensive examples
- iOS Integration Guide – Detailed CocoaPods setup
- Release Notes – Latest updates and changes
All trademarks of Eclypses Inc. may not be used without Eclypses Inc.'s prior written consent.