導(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ù)類型的默認應(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)注
61文章
1665瀏覽量
182509 -
鴻蒙
+關(guān)注
關(guān)注
59文章
2588瀏覽量
43951
發(fā)布評論請先 登錄

NFC智能手表標簽:一鍵觸發(fā)網(wǎng)頁與應(yīng)用,還可以刷門禁 #nfc手環(huán) #NFC標簽







NFC硅膠腕帶網(wǎng)址讀寫應(yīng)用演示 #nfc #NFC標簽 #手環(huán)手表 #智能手環(huán) #硅膠腕帶



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


消費類電子標簽NFC手環(huán)標簽 #NFC標簽 #nfc手環(huán) #硅膠手環(huán)標簽 #nfc


評論