【问题标题】:How do I make a phone call with nativescript?如何使用 nativescript 拨打电话?
【发布时间】:2019-09-20 11:47:06
【问题描述】:

我想在按下按钮时拨打电话。 我打电话给标签的电话号码。 这是我的按钮;

<ActionBar>
    <NavigationButton (tap)="onBackTap()" android.systemIcon="ic_menu_back"></NavigationButton>
    <Label class="action-bar-title" style="font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 10px;" [text]="item.name"></Label>
</ActionBar>

<StackLayout>
<Label class="action-bar-title" style="font-family: Georgia, 'Times New Roman', Times, serif;
        font-size: 10px;" [text]="item.number"></Label>
    <Button text="&#xff17b; Call!" (tap)="onTap()" class="my-button"></Button>
</StackLayout>

这是我的 onTap() 方法;

export class ItemDetailComponent implements OnInit {
    item: IDataItem;

    constructor(
        private _data: DataService,
        private _route: ActivatedRoute,
        private _routerExtensions: RouterExtensions
    ) { }

    ngOnInit(): void {
        const id = +this._route.snapshot.params.id;
        this.item = this._data.getItem(id);
    }

    onBackTap(): void {
        this._routerExtensions.back();
    }
    onTap(): void {

    }
}

如何拨打电话?

【问题讨论】:

  • @Igor 请在重复之前阅读标签。这是关于 Nativescript 而您提供的链接仅与 Web 和 Android 有关。 Nativescript 和 Android 特定的东西完全不同。
  • @user3502626 - 您应该能够看到问题的编辑历史记录以及评论日期。这个问题是在 9 月创建的。 2019 年,当时我建议可能重复。 2 个月后,您所指的标签被另一个用户添加。从那时起(2019 年 11 月),没有任何活动。

标签: angular typescript nativescript nativescript-angular


【解决方案1】:

您可以使用插件NativeScript Phone

现在你有两个选择:

  1. 直接从应用程序拨打电话 - 您需要CALL_PHONE 的权限。

  2. 打开默认电话应用并输入号码。

在我看来,第二个选项更好,因为您不需要任何额外的权限。

导入 TNSPhone:

import * as TNSPhone from 'nativescript-phone';

并在您的onTap 方法中使用拨号方法:

TNSPhone.dial(123456789, true);

【讨论】:

    猜你喜欢
    • 2017-11-26
    • 1970-01-01
    • 1970-01-01
    • 2018-05-22
    • 2014-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多