拨号器未显示完整的 ussd 代码,例如:*123*1#
The dialer is not showing full ussd code eg: *123*1#
我正在使用 url_launcher
插件进行通话,但拨号器未显示 #
字符:
String url = 'tel:*123#';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
您需要使用 URL encoding 作为 URL 中的特殊字符。
所以 #
等于 %23
这会起作用launch('tel:\*123\%23');
另一种方法是对用户输入的数字进行编码,然后通过 Uri.encodeFull(urlString
) 或 Uri.encodeComponent(urlString)
传递
像这样。
launch("tel:" + Uri.encodeComponent('*123#'));
免责声明:plugin作者在此。
您要打开 phone 呼叫用户界面还是静默发出请求?如果你喜欢不弹出 phone 调用 UI,Android 在 API 级别 26 中介绍的方法 sendUssdRequest.
我制作了一个名为 ussd_service 的 Flutter 插件,以便能够在 Flutter 应用程序中从 dart 轻松访问它。可以通过以下方式使用:
import 'package:ussd_service/ussd_service.dart';
makeMyRequest() async {
int subscriptionId = 1; // sim card subscription Id
String code = "*21#"; // ussd code payload
try {
String ussdSuccessMessage = await UssdService.makeRequest(subscriptionId, code);
print("succes! message: $ussdSuccessMessage");
} on PlatformException catch (e) {
print("error! code: ${e.code} - message: ${e.message}");
}
};
makeMyRequest();
希望对您有所帮助!如果您对 Github repo 的问题有任何疑问,请告诉我。
我正在使用 url_launcher
插件进行通话,但拨号器未显示 #
字符:
String url = 'tel:*123#';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
您需要使用 URL encoding 作为 URL 中的特殊字符。
所以 #
等于 %23
这会起作用launch('tel:\*123\%23');
另一种方法是对用户输入的数字进行编码,然后通过 Uri.encodeFull(urlString
) 或 Uri.encodeComponent(urlString)
像这样。
launch("tel:" + Uri.encodeComponent('*123#'));
免责声明:plugin作者在此。
您要打开 phone 呼叫用户界面还是静默发出请求?如果你喜欢不弹出 phone 调用 UI,Android 在 API 级别 26 中介绍的方法 sendUssdRequest.
我制作了一个名为 ussd_service 的 Flutter 插件,以便能够在 Flutter 应用程序中从 dart 轻松访问它。可以通过以下方式使用:
import 'package:ussd_service/ussd_service.dart';
makeMyRequest() async {
int subscriptionId = 1; // sim card subscription Id
String code = "*21#"; // ussd code payload
try {
String ussdSuccessMessage = await UssdService.makeRequest(subscriptionId, code);
print("succes! message: $ussdSuccessMessage");
} on PlatformException catch (e) {
print("error! code: ${e.code} - message: ${e.message}");
}
};
makeMyRequest();
希望对您有所帮助!如果您对 Github repo 的问题有任何疑问,请告诉我。