executeUssdDirect method
Executes a USSD code directly and gets the response without showing the native system dialog (Android only)
ussdCode - The USSD code to execute
timeoutSeconds - Timeout in seconds
subscriptionId - (Optional) Subscription ID (SIM slot).
If not provided and there are multiple SIMs, the native selector will be shown.
If there is only one SIM, it is used by default.
iosFallbackToStandard - (iOS only) If true, uses executeUssd as fallback.
Implementation
@override
Future<String?> executeUssdDirect(
String ussdCode,
int timeoutSeconds, {
int? subscriptionId,
bool iosFallbackToStandard = false,
}) async {
try {
final Map<String, dynamic> arguments = {
'ussdCode': ussdCode,
'timeoutSeconds': timeoutSeconds,
'iosFallbackToStandard': iosFallbackToStandard,
};
if (subscriptionId != null) {
arguments['subscriptionId'] = subscriptionId;
}
final result = await methodChannel.invokeMethod<String>(
'executeUssdDirect',
arguments,
);
return result;
} on PlatformException catch (e) {
debugPrint('Error executing direct USSD: ${e.message}');
return null;
}
}