導(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
返回值:
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)注
59文章
1640瀏覽量
181283 -
鴻蒙
+關(guān)注
關(guān)注
57文章
2410瀏覽量
43291
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦


NFC防偽溯源標(biāo)簽在供應(yīng)鏈管理中的應(yīng)用 #nfc標(biāo)簽 #防偽溯源標(biāo)簽




NFC標(biāo)簽讀取網(wǎng)址演示 #nfc #NFC標(biāo)簽 #nfc標(biāo)簽


NFC IC配置工具NFC Cockpit的主要特性


消費(fèi)類電子標(biāo)簽NFC手環(huán)標(biāo)簽 #NFC標(biāo)簽 #nfc手環(huán) #硅膠手環(huán)標(biāo)簽 #nfc

普通NFC標(biāo)簽和NFC抗金屬標(biāo)簽有什么區(qū)別呢? #NFC標(biāo)簽 #抗金屬標(biāo)簽

NFC環(huán)保易碎銀漿天線撕碎應(yīng)用演示 #NFC標(biāo)簽 #環(huán)保易碎標(biāo)簽

評(píng)論