導入模塊
import cardEmulation from '@ohos.nfc.cardEmulation';
FeatureType
定義不同的NFC卡模擬類型。
NOTE
從 API version 6 開始支持,從 API version 9 開始廢棄,建議使用hasHceCapability替代。
系統能力: SystemCapability.Communication.NFC.CardEmulation

CardType9+
定義卡模擬應用所使用的業務類型,是支付類型,還是其他類型。
系統能力: SystemCapability.Communication.NFC.CardEmulation

isSupported
isSupported(feature: number): boolean
是否支持某種類型的卡模擬。
NOTE
從 API version 6 開始支持,從 API version 9 開始廢棄,建議使用hasHceCapability替代。
系統能力: SystemCapability.Communication.NFC.CardEmulation
參數:

返回值:

hasHceCapability9+
hasHceCapability(): boolean
判斷是否支持HCE功能。
系統能力: SystemCapability.Communication.NFC.CardEmulation
需要權限: ohos.permission.NFC_CARD_EMULATION
返回值:

isDefaultService9+
isDefaultService(elementName: ElementName, type: CardType): boolean
判斷指定的應用是否為指定業務類型的默認應用。
系統能力: SystemCapability.Communication.NFC.CardEmulation
需要權限: ohos.permission.NFC_CARD_EMULATION
參數:

返回值:

示例:
import cardEmulation from '@ohos.nfc.cardEmulation';
var isHceSupported = cardEmulation.isSupported(cardEmulation.FeatureType.HCE);
if (!isHceSupported) {
console.log('this device is not supported for HCE, ignore it.');
return;
}
var hasHceCap = cardEmulation.hasHceCapability();
if (!hasHceCap) {
console.log('this device hasHceCapability false, ignore it.');
return;
}
var elementName = {
"bundleName": "com.test.cardemulation",
"abilityName": "com.test.cardemulation.MainAbility",
};
var isDefaultService = cardEmulation.isDefaultService(elementName, cardEmulation.CardType.PAYMENT);
console.log('is the app is default service for this card type: ' + isDefaultService);
審核編輯 黃宇
-
nfc
+關注
關注
62文章
1735瀏覽量
185610 -
鴻蒙
+關注
關注
60文章
2963瀏覽量
45905
發布評論請先 登錄
使用X-NUCLEO-NFC08A1開發板評估st25R3916b,這款芯片在nfc讀寫時能做到的最小電流是多少?
鴻蒙開發之@ohos.nfc.cardEmulation (標準NFC-cardEmulation)
評論