Ionic CallNumber原生Cordova插件无法正常工作 - Ionic 3,Angular 4

3

我知道在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": {}
        }
    }
}

你是在使用设备还是模拟器? - Sampath
你能展示一下 package.json 文件吗? - Sampath
@Sampath 我正在使用 iPhone 7 和 HTC M10+ 设备。 - Murlidhar Fichadia
@Sampath 我已经添加了 package.json 文件。 - Murlidhar Fichadia
3个回答

6

我通过简单地使用以下方法使其工作:

<a href="tel:+1234567890">CALL</a>

请确保在config.xml文件中有以下代码

<allow-intent href="tel:*" />

其他可能支持的 href,用于在默认浏览器、电子邮件应用程序或短信应用程序中打开链接:

<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />

这在我的 ios(Ionic v3)上不起作用。在Android上可以正常工作。 - Timmy O'Mahony

0

我留下答案,为那些仍在寻找的人提供帮助。

首先请参考这个 Ionic 页面。

[a link]https://ionicframework.com/docs/native/call-number/[a 链接]

如果您决定升级 Angular 版本,您将遇到不兼容的问题,这将花费您很多时间。否则,如果您遇到编译问题,例如找不到 isCallSupported() 属性,请查找 API 的旧版本。


0

移除 mx.ferreyra.callnumber 并替换为 "call-number" 已被认为是一种临时解决方案。

{
    "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": {
            "call-number": {},
            "cordova-plugin-googlemaps": {}
        }
    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接