ussd_service 0.1.0+4

Flutter Android iOS

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:

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,
        Duration(seconds: 10), // timeout (optional) - default is 10 seconds
    );
    print("succes! message: $ussdResponseMessage");
  } catch(e) {
    debugPrint("error! code: ${e.code} - message: ${e.message}");
  }
};

void main() => makeMyRequest();

Interactive / multi steps USSD sessions #

Android's sendUssdRequest doesn't support interactive / multi steps USSD sessions, so this plugin doesn't support them either. However, as mentioned by a user who reported it in a comment, you may be able to achieve similar behaviour by passing all arguments in a single USSD request.

*firstCode*2ndCode*3rdCode*4thCode*..*..#
20
likes
100
pub points
76%
popularity

Publisher

vincent-kammerer.com

A Flutter plugin to make silent USSD requests and read their responses, using Android's sendUssdRequest. iOS is not supported.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on ussd_service