Issue
I need to make a direct Phone Call in flutter but it's just opening the Phone app dialer.
No direct phone call is made.
In fact, I also tried with url_launcher
package for this task but am getting the same result.
_launchURL() async {
SimplePermissions.requestPermission(Permission.CallPhone)
.then((state) async {
if (state == PermissionStatus.authorized) {
String a = Uri.encodeFull("#");
String url = 'tel:*123' + a;
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
});}
Has anyone solved this before?
Solution
Disclaimer: plugin author here.
Since Android API level 26, the method sendUssdRequest is exposed to make silent USSD requests.
I made a Flutter plugin called ussd_service to be able to easily access it from dart in a Flutter application. It can be used in the following manner:
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();
Hope this helps! Let me know on the Github repo's issues if you have any issue with it.
Answered By - vkammerer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.