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

CardType9+
定義卡模擬應(yīng)用所使用的業(yè)務(wù)類型,是支付類型,還是其他類型。
系統(tǒng)能力: SystemCapability.Communication.NFC.CardEmulation

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

返回值:

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

isDefaultService9+
isDefaultService(elementName: ElementName, type: CardType): boolean
判斷指定的應(yīng)用是否為指定業(yè)務(wù)類型的默認(rèn)應(yīng)用。
系統(tǒng)能力: SystemCapability.Communication.NFC.CardEmulation
需要權(quán)限: ohos.permission.NFC_CARD_EMULATION
參數(shù):

返回值:

示例:
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
+關(guān)注
關(guān)注
62文章
1735瀏覽量
185640 -
鴻蒙
+關(guān)注
關(guān)注
60文章
2963瀏覽量
45928
發(fā)布評(píng)論請(qǐng)先 登錄
品牌防偽升級(jí):NFC易碎標(biāo)簽全流程管控 #NFC標(biāo)簽 #易碎標(biāo)簽 #rfid標(biāo)簽
從防偽到營(yíng)銷,NFC標(biāo)簽如何提升品牌價(jià)值 #nfc標(biāo)簽貼 #NFC標(biāo)簽 #防偽溯源標(biāo)簽
一貼即用,NFC標(biāo)簽讓信息交互更高效 #nfc標(biāo)簽 #nfc標(biāo)簽貼 #高頻標(biāo)簽
貼在金屬上也靈敏,NFC抗金屬標(biāo)簽讓資產(chǎn)管理更可靠 #NFC標(biāo)簽 #抗金屬標(biāo)簽
NFC硅膠腕帶標(biāo)簽,輕松實(shí)現(xiàn)身份識(shí)別與支付 #NFC標(biāo)簽 #腕帶標(biāo)簽 #手環(huán)標(biāo)簽
NFC智能手表標(biāo)簽:一鍵觸發(fā)網(wǎng)頁(yè)與應(yīng)用,還可以刷門禁 #nfc手環(huán) #NFC標(biāo)簽
使用X-NUCLEO-NFC08A1開發(fā)板評(píng)估st25R3916b,這款芯片在nfc讀寫時(shí)能做到的最小電流是多少?
從防偽溯源到智能控制,NFC標(biāo)簽的應(yīng)用場(chǎng)景 #nfc #NFC標(biāo)簽
從防偽到營(yíng)銷:NFC標(biāo)簽如何重塑品牌消費(fèi)體驗(yàn) #NFC標(biāo)簽 #防偽溯源標(biāo)簽
FPC抗金屬NFC標(biāo)簽應(yīng)用演示 #NFC標(biāo)簽 #抗金屬標(biāo)簽
NFC茶葉防偽NFC標(biāo)簽包裝防偽讀寫應(yīng)用演示 #nfc #防偽溯源標(biāo)簽 #nfc防偽標(biāo)簽
鴻蒙開發(fā)之@ohos.nfc.cardEmulation (標(biāo)準(zhǔn)NFC-cardEmulation)
評(píng)論