The plugin allows the use of the `Android TelephonyManager UssdResponseCallBack` method to dial ussd short codes programmatically and get the response text asynchronously
npm install @veelit/capacitor-ussd-managerThe 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).
``bash`
npm install @veelit/capacitor-ussd-manager
npx cap sync
Add the following permission to your AndroidManifest.xml
``
* echo(...)
* requestUssdPermission()
* callUssd(...)
`typescript`
echo(options: { value: string; }) => Promise<{ value: string; }>
| Param | Type |
| ------------- | ----------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
---
`typescript`
requestUssdPermission() => Promise
---
`typescript`
callUssd(options: { value: string; }) => Promise<{ result: string; code: string; }>
| Param | Type |
| ------------- | ----------------------------------- |
| options | { value: string; } |
Returns: Promise<{ result: string; code: string; }>
---
`typescript
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));
}
};
``