@veelit/capacitor-ussd-manager
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

capacitor-ussd-manager

The plugin allows the use of the Android TelephonyManager UssdResponseCallBack method to dial ussd short codes programmatically and get the response text asynchronously.

Note: This only supports USSD codes that are not session based (i.e where user input is not required after dialling the code).

Install

npm install @veelit/capacitor-ussd-manager
npx cap sync

Permissions

Add the following permission to your AndroidManifest.xml

<uses-permission android:name="android.permission.CALL_PHONE" />

API

echo(...)

echo(options: { value: string; }) => Promise<{ value: string; }>
Param Type
options <code>{ value: string; }</code>

Returns: <code>Promise<{ value: string; }></code>


requestUssdPermission()

requestUssdPermission() => Promise<void>

callUssd(...)

callUssd(options: { value: string; }) => Promise<{ result: string; code: string; }>
Param Type
options <code>{ value: string; }</code>

Returns: <code>Promise<{ result: string; code: string; }></code>


Example Usage

import { UssdManager } from '@veelit/capacitor-ussd-manager';

const callUssdCode = async (shortCode: string) => {
  try {
    await UssdManager.requestUssdPermission();
    const res = await UssdManager.callUssd({ value: shortCode });
    setUssdResponse(res);
  } catch (error: any) {
    setUssdResponse(JSON.parse(error?.message));
  }
};

Readme

Keywords

Package Sidebar

Install

npm i @veelit/capacitor-ussd-manager

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

24 kB

Total Files

41

Last publish

Collaborators

  • r2g