From 57bbcdebfbcdb8c66839b31afd4445c9ac5f802b Mon Sep 17 00:00:00 2001 From: foysal Date: Thu, 24 Aug 2017 01:37:31 +0200 Subject: [PATCH] docs(nfc): update usage doc of the nfc plugin (#1846) * docs(nfc): update usage doc of the nfc plugin show an example of how the event listeners work with observable subscription and implement an nfc share within the event listener. * docs(AndroidPermissions): requestPermissions->requestPermission --- .../plugins/android-permissions/index.ts | 2 +- src/@ionic-native/plugins/nfc/index.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/@ionic-native/plugins/android-permissions/index.ts b/src/@ionic-native/plugins/android-permissions/index.ts index 68af9ddb2..daa3ddfe2 100644 --- a/src/@ionic-native/plugins/android-permissions/index.ts +++ b/src/@ionic-native/plugins/android-permissions/index.ts @@ -19,7 +19,7 @@ import { Injectable } from '@angular/core'; * * this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.CAMERA).then( * success => console.log('Permission granted'), - * err => this.androidPermissions.requestPermissions(this.androidPermissions.PERMISSION.CAMERA) + * err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.CAMERA) * ); * * this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.CAMERA, this.androidPermissions.PERMISSION.GET_ACCOUNTS]); diff --git a/src/@ionic-native/plugins/nfc/index.ts b/src/@ionic-native/plugins/nfc/index.ts index 4a3f4bc44..536506b3a 100644 --- a/src/@ionic-native/plugins/nfc/index.ts +++ b/src/@ionic-native/plugins/nfc/index.ts @@ -23,8 +23,17 @@ declare let window: any; * * ... * - * let message = this.ndef.textRecord('Hello world'); - * this.nfc.share([message]).then(onSuccess).catch(onError); + * this.nfc.addNdefListener(() => { + * console.log('successfully attached ndef listener'); + * }, (err) => { + * console.log('error attaching ndef listener', err); + * }).subscribe((event) => { + * console.log('received ndef message. the tag contains: ', event.tag); + * console.log('decoded tag id', this.nfc.bytesToHexString(event.tag.id)); + * + * let message = this.ndef.textRecord('Hello world'); + * this.nfc.share([message]).then(onSuccess).catch(onError); + * }); * * ``` */