Dialing USSD with ionic2


#1

Hi,
I am unable to dial USSD codes with ionic 2. Normal calls work with href=“tel:123” but not USSDs href="123#". As soon as you put a star '’ it wouldn’t dial. Can someone help me out?


#2

I got it worked by using @ionic-native/call-number. Just npm installed it , then add this to your module.ts file :
import { CallNumber } from '@ionic-native/call-number'; .. .. .. providers: [CallNumber]

Then in your html , add an input line:
<button ion-button (click)="callIT('*111#')">Dial Now! </button>

And finally, in the .ts file:

import { CallNumber } from '@ionic-native/call-number';

constructor(private callNumber: CallNumber) {}


callIT(passedNumber){

    this.callNumber.callNumber(passedNumber, true)
      .then((data) => {
        console.log('Launched dialer!'+ data);
      })
      .catch(() => console.log('Error launching dialer'));
  }

When you click on the ‘Dial Now!’ button, the callIT() function fires up and you should see the USSD dialog launched with the response of the code!


#3

Let’s say I use this for phone balance checking… Will I be able to parse the result and display it the way I want in the UI ?


#4

@ionic-native/call-number only fires the system dialer, and here’s the problem which I needed to resolve too , that it cannot be parsed ! All I get is the response via the system dialer , but can’t parse it as I want to show in my UI , and did not find any parser library to do it till now ! I had posted a ques regarding this months ago in this forum , but no luck !