sdk final
This commit is contained in:
@@ -7,27 +7,30 @@ import 'package:flutter/services.dart';
|
||||
class TrustAPPHttpdns {
|
||||
static const MethodChannel _channel = MethodChannel('TrustAPP_httpdns');
|
||||
|
||||
/// New API only:
|
||||
/// appId + primary/backup service host + optional sign secret.
|
||||
/// Initialize the SDK.
|
||||
/// [apiUrl] is the unified endpoint URL, e.g. "https://httpdns.example.com:8445".
|
||||
/// [appId] and [secretKey] are required for authentication.
|
||||
static Future<bool> init({
|
||||
required String appId,
|
||||
required String primaryServiceHost,
|
||||
String? backupServiceHost,
|
||||
int servicePort = 443,
|
||||
String? apiUrl,
|
||||
@Deprecated('Use apiUrl instead') String? primaryServiceHost,
|
||||
@Deprecated('Use apiUrl instead') String? backupServiceHost,
|
||||
@Deprecated('Use apiUrl instead') int servicePort = 443,
|
||||
String? secretKey,
|
||||
}) async {
|
||||
final String normalizedAppId = appId.trim();
|
||||
final String normalizedPrimary = primaryServiceHost.trim();
|
||||
if (normalizedAppId.isEmpty || normalizedPrimary.isEmpty) {
|
||||
if (normalizedAppId.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Map<String, dynamic> args = <String, dynamic>{
|
||||
'appId': normalizedAppId,
|
||||
'primaryServiceHost': normalizedPrimary,
|
||||
if (apiUrl != null && apiUrl.trim().isNotEmpty) 'apiUrl': apiUrl.trim(),
|
||||
if (primaryServiceHost != null && primaryServiceHost.trim().isNotEmpty)
|
||||
'primaryServiceHost': primaryServiceHost.trim(),
|
||||
if (backupServiceHost != null && backupServiceHost.trim().isNotEmpty)
|
||||
'backupServiceHost': backupServiceHost.trim(),
|
||||
if (servicePort > 0) 'servicePort': servicePort,
|
||||
'servicePort': servicePort,
|
||||
if (secretKey != null && secretKey.isNotEmpty) 'secretKey': secretKey,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user