How to send and receive USSD codes with ionic plat

2019-09-10 03:40发布

I'm a junior developer in Ionic platform, now I have a problem to send and receive USSD codes with that .... please help me is you know about that.

2条回答
混吃等死
2楼-- · 2019-09-10 04:06

From what I have found on internet and tested, you can send USSD codes

<a href="tel:YOUR_NUMBER" class="button button-positive">Call me? </a>

and to make it functional you need to provide access in CONFIG.XML, simple add

<access origin="tel:*" launch-external="yes"/>

only disadvantage is: it will not directly dial your number rather open it in default Dailer of device.

Note: I'm newbie here on Stack so don't know formal ways of answering. have fun coding!

查看更多
成全新的幸福
3楼-- · 2019-09-10 04:11

I would suggest using Call Number native plugin. It allows you to make phone calls and send USSD codes. On Android, it sends the USSD codes directly, without launching a phone app.

  1. Install the plugin as explained in the docs.
  2. Use it to send USSD codes.

Example:

import { Component } from '@angular/core';
import { CallNumber } from "@ionic-native/call-number";

@Component({
  selector: 'page-home',
  template: `
    <button ion-button (click)="callNumber()">CallNumber</button>
  `
})
export class HomePage {

  constructor(public phone: CallNumber) { }

  callNumber(){
    this.phone.callNumber("123456789", true)
      .then(res => this.result = res)
      .catch(err => this.result = err);
  }
}
查看更多
登录 后发表回答