首页 > 解决方案 > How to use Apple Pay in NativeScript

问题描述

I'm trying to make Apple Pay in NativeScript app by using native code.
But have some errors with data type (?)

let item = new PKPaymentSummaryItem();
item.label = "iPhone Xs 64 Gb";
item.amount = 39999;

JavaScript error:

file:///app/components/Home.vue:24:0 JS ERROR Error: -[__NSCFNumber decimalNumberByRoundingAccordingToBehavior:]: unrecognized selector sent to instance 0xf549d0dbe6e8cc69

标签: javascriptnativescriptapplepay

解决方案


正如错误消息所示,您需要正确进行打字转换。将软件包安装tns-platform-declarations为项目的开发依赖项将为您提供方便的智能感知,它将指导您解决此类问题。对于这种特殊情况,请尝试:

item.amount = new NSDecimalNumber({ string: "29999" });

推荐阅读