2-call ion number not working

I will not write an application that can call by user number.

But I use http://ionicframework.com/docs/v2/native/callnumber/ , it does not work.

this is my ts code

import { Component } from '@angular/core'; import {CallNumber} from 'ionic-native'; import { Platform, ActionSheetController } from 'ionic-angular'; // import { NavController } from 'ionic-angular'; declare var window; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { constructor( public platform: Platform, public actionsheetCtrl: ActionSheetController ) { } strShowInHtml = ""; callIT(){ // window.location = '12345'; CallNumber.callNumber("12345", true) .then(() =>{ console.log('Launched dialer!'); this.strShowInHtml="ok"; }) .catch(() => { console.log('Error launching dialer'); this.strShowInHtml="error"; }); } } 

and my html code:

 <ion-header> <ion-navbar> <ion-title>Action Sheets</ion-title> </ion-navbar> </ion-header> <ion-content padding class="action-sheets-basic-page"> <button md-button (click)="callIT()">callIT</button> </ion-content> 

I know I can use

 <a ion-button href="tel:+0839504890">Call me 1 </a> 

but I don’t want to use it, beaucase it will go to view Call Phone. I want to press a button and my Ionic 2 application will dial the user number.

+6
source share
5 answers

In your component class write below

 callIT(mobNumber:string) { window.open("tel:" + mobNumber); } 
+6
source

Import is not complete. The documentation says how to install the plugin call number:

 $ ionic plugin add --save call-number $ npm install --save @ionic-native/call-number 

And then refer to the plugin:

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

I used this method the other day. and worked :) Hope this works for you.

  import {CallNumber} from '@ionic-native/call-number'; constructor(public navCtrl: NavController, public navParams: NavParams,public call:CallNumber){} async callNumber():Promise<any>{ try{ await this.call.callNumber("+XXXXXXXXX",true); } catch(e){ console.log(e); } } 
0
source

Just do this to solve the problem:

0
source
  <ion-fab left bottom> <a href="tel:number" class="button" ion-fab color="light"> <ion-icon name="keypad"></ion-icon> </a> </ion-fab> 

Use this cordova plugin

 mx.ferreyra.callnumber 0.0.2 "Cordova Call Number Plugin" 
0
source

Source: https://habr.com/ru/post/1012241/


All Articles