0.0.4 • Published 1 year ago

@veelit/capacitor-ussd-manager v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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; }>
ParamType
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; }>
ParamType
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));
  }
};
0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago