ussd_service 0.0.3+1 ussd_service: ^0.0.3+1 copied to clipboard
A Flutter plugin to make silent USSD requests and read their responses, using Android's sendUssdRequest. iOS is not supported.
Ussd plugin for Flutter #
This plugin makes it possible to access Android's sendUssdRequest method from a Flutter application.
Installation #
Add ussd_service
as a dependency in your pubspec.yaml.
Make sure that your AndroidManifext.xml
file includes the following permission:
<uses-permission android:name="android.permission.CALL_PHONE" />
Usage #
Before you use this plugin, you must:
- make sure that the user has authorized access to his phone calls, for example with the permission_handler plugin.
- retrieve the SIM card subscription ID, for example with the sim_service plugin.
You may then use the plugin:
import 'package:ussd_service/ussd_service.dart';
makeMyRequest() async {
int subscriptionId = 1; // sim card subscription ID
String code = "*21#"; // ussd code payload
try {
String ussdResponseMessage = await UssdService.makeRequest(subscriptionId, code);
print("succes! message: $ussdResponseMessage");
} catch(e) {
debugPrint("error! code: ${e.code} - message: ${e.message}");
}
};
makeMyRequest();