How to send and receive USSD codes with ionic platform?

我与影子孤独终老i 提交于 2019-12-12 03:33:38

问题


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.


回答1:


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!




回答2:


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


来源:https://stackoverflow.com/questions/35196136/how-to-send-and-receive-ussd-codes-with-ionic-platform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!