I want to dial USSD code via my Ionic app and re-request the channel based on that response, the same way we interact with telcos to know about balance/internet packages etc (Dial USSD code and press 1/2/3 etc option to continue next). But it is only showing via phone’s default USSD dialog/ Dialer. Is there any way in Ionic2 to get the USSD response as text or other readable format so that I can parse it inside my app?
Hi did you find a solution please?
If anyone still looking for this, you can use this plugin cordova-plugin-ussd - npm
npm i cordova-plugin-ussd
cordova plugin add cordova-plugin-ussd or cordova plugin add GitHub - NeielHQ/cordova-plugin-ussd: Cordova plugin for dialing USSD code
In you ts file add under imports: declare var ussd: any;
and use the dial function
ussd.dial(‘12030#’, 1,
function (response: any) {
//response is the message returned from dialing the USSD code .
// For example “Your data balance is 12GB”
alert(dialUssd ${response});
console.log(dialUssd ${response});
},
function (error: any) {
//error message from the native code, it contains:
// failureCode + request
alert(error)
}
)
if your phone support double SIM and you don’t have a second SIM card
change the line 36 in yourProject\plugins\ng.neiel.cordova.plugins.ussd\src\android\Ussd.java to
TelephonyManager manager2 = SIM2_id != null ? manager.createForSubscriptionId(SIM2_id.getSubscriptionId()) : null;
and reinstall cordova platform