@Vartex05 wrote:
Hi, iam using cordova nfc plugin in my app, to read nfc tag, then i check if it is correct on the server and i navigate to next page, or activate reader again.My code in service(userService) looks like this:
public startReading(){ return new Promise((resolve,reject)=>{ nfc.readerMode(nfc.FLAG_READER_NFC_A,(tag)=>{ nfc.disableReaderMode(); resolve(this.transformTag(tag.id)); },err=>{ console.log(err); nfc.disableReaderMode(); reject(err); }); }); }
and in my page i use it like this:
ionViewWillEnter(){ console.log("nfcAktivaceLogin"); this.platform.ready().then(()=>{ this.userService.startReading().then((tagId)=>{ console.log("tagid",tagId); this.uisLogin(tagId); }); }) } uisLogin(tagID){ let loading=this.loadingCtrl.create({ spinner:'crescent' }); loading.present(); this.productService.loginEmployee(tagID).subscribe((data)=>{ console.log("Výsledek",data); loading.dismiss(); this.navCtrl.push(HomePage); }, err=>{ loading.dismiss(); this.userService.startReading().then((tagId)=>{ console.log("tagid",tagId); this.uisLogin(tagId); }); let alert = this.alertCtrl.create({ title: err.message, buttons: ['OK'] }); alert.present(); }); }
In uisLogin Method, iam calling itself inside it, is it a problem? I kinda think that it isnt the best solution, but it seems to be working. Any ideas?
Posts: 1
Participants: 1