Я пытаюсь прочитать данные с моей студенческой карточки с помощью Ioni c и @ ioni c -native / nf c.
Мне удалось сделать nf c .connect и один nf c .transceive, но я застрял с вызовами nf c .transceive (у меня есть это в свойствах класса)
nfc:NFC;
rapoince:string;
messageC:string;
this.nfc.transceive(this.forgeADPU(0xAA,this.toHex(parseInt('0x01')).toString())).then((response)=>{
this.raiponce = this.ArrayBufferToString(response);
//some lines
this.messageC = aesjs.utils.hex.fromBytes(aesCbc.encrypt(temp));
// some lines
})
У меня проблема в том, что я я пытаюсь использовать this.message C в другом вызове this.nf c .transceive, но я не могу этого сделать. Я пытался сделать это, читая некоторые сообщения на форуме, но это не работает:
this.nfc.transceive(this.forgeADPU(0xAA,this.toHex(parseInt('0x01')).toString())).then((response)=>{
//some lines
}).then (function(){
this.nfc.transceive(this.forgeADPU(0xAF, this.messageC)).then((response)=>{
let reponse = this.ArrayBufferToString(response);
console.log('Raiponce authentification 2 : ' + reponse);
//test isAF (a créer)
})
})
Проблема с этим решением заключается в том, что this.nf c не существует во втором вызове transceive. Подпись функции передачи плагина:
transceive(data: string | ArrayBuffer): Promise<ArrayBuffer>;
/**
* Starts the NFCNDEFReaderSession allowing iOS to scan NFC tags.
* @deprecated use scanNdef or scanTag
*
* @param onSuccess
* @param onFailure
* @returns {Observable<any>}
*/
Как я могу решить эту проблему?