我知道在Stackoverflow、Ionic论坛和其他地方都有相关解决方案。但是,当我在Android和IOS上测试时,这些解决方案都不适用于我。
https://ionicframework.com/docs/native/call-number/
让我向您展示我遵循的确切步骤:
1)运行命令:ionic cordova plugin add call-number
2)运行命令:npm install --save @ionic-native/call-number
3)在app.module.ts中添加import { CallNumber } from '@ionic-native/call-number';
4)添加提供者CallNumber
5)最后,...
import { CallNumber } from '@ionic-native/call-number';
constructor(private callNumber: CallNumber) { }
...
this.callNumber.callNumber("18001010101", true)
.then(() => console.log('Launched dialer!'))
.catch(() => console.log('Error launching dialer'));
我甚至尝试过使用async和promise:
async telephoneCall(): Promise<any>{
try{
await this.callNumber.callNumber(String('18001010101'), true);
}catch(e){
console.log("User Error: "+ e);
}
}
以上解决方案在编译时或运行时均未出现错误,我不确定问题出在哪里。 我正在使用Ionic 3和Angular 4,有没有针对这个框架版本的解决方案?
更新
{
"name": "App Name",
"version": "0.0.1",
"author": "Murlidhar Fichadia",
"homepage": "#",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.4.3",
"@angular/compiler": "4.4.3",
"@angular/compiler-cli": "4.4.3",
"@angular/core": "4.4.3",
"@angular/forms": "4.4.3",
"@angular/http": "4.4.3",
"@angular/platform-browser": "4.4.3",
"@angular/platform-browser-dynamic": "4.4.3",
"@ionic-native/call-number": "^4.3.2",
"@ionic-native/core": "4.3.2",
"@ionic-native/google-maps": "^4.3.2",
"@ionic-native/splash-screen": "4.3.2",
"@ionic-native/status-bar": "4.3.2",
"@ionic/storage": "2.0.1",
"call-number": "^1.0.1",
"cordova-plugin-googlemaps": "^2.0.11",
"ionic-angular": "3.7.1",
"ionicons": "3.0.0",
"rxjs": "5.4.3",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
"devDependencies": {
"@ionic/app-scripts": "3.0.1",
"typescript": "2.3.4"
},
"description": "App Description",
"cordova": {
"plugins": {
"mx.ferreyra.callnumber": {},
"cordova-plugin-googlemaps": {}
}
}
}
package.json
文件吗? - Sampath