doc: include ReWriter android app link

This commit is contained in:
richie 2021-10-19 11:22:05 +08:00
parent 1072faab45
commit 280f3a2310
2 changed files with 43 additions and 35 deletions

View File

@ -8,7 +8,7 @@ Bring NFC feature to React Native. Inspired by [phonegap-nfc](https://github.com
Contributions are welcome!
> We also have a slack channel, you're welcome to chat with us for any issue or idea! [join us here](https://join.slack.com/t/reactnativenf-ewh2625/shared_invite/zt-puz9y22v-3rkORO6_zQe4FmaWm6ku_w)
Made with ❤️ by [whitedogg13](https://github.com/whitedogg13) and [revteltech](https://github.com/revtel)
## Install
@ -41,16 +41,15 @@ We have a full featured NFC utility app available for download.
<a href='https://apps.apple.com/tw/app/nfc-rewriter/id1551243964' target='_blank'>
<img alt="react-native-nfc-rewriter" src="./images/Apple-App-Store-Icon.png" width="250">
</a>
<br/>
</br>
<a href='https://play.google.com/store/apps/details?id=com.washow.nfcopenrewriter' target='_blank'>
<img alt="react-native-nfc-rewriter" src="./images/google-play-icon.jpeg" width="250">
</a>
It also open sourced in this repo: [React Native NFC ReWriter App](https://github.com/revtel/react-native-nfc-rewriter)
### [Bonus] Reconnect.js
Super useful library to help you share states between `sibling` and `nested` React components.
[Check it out!](https://github.com/revtel/reconnect.js)
## Basic Usage
If all you want to do is to read `NDEF` data, you can use this example:
@ -163,41 +162,49 @@ async function initNfc() {
async function readMifare() {
try {
// 0. Request Mifare technology
let reqMifare = await NfcManager.requestTechnology(NfcTech.MifareUltralight);
if (reqMifare !== 'MifareUltralight') {
throw new Error('[NFC Read] [ERR] Mifare technology could not be requested');
};
// 0. Request Mifare technology
let reqMifare = await NfcManager.requestTechnology(
NfcTech.MifareUltralight,
);
if (reqMifare !== 'MifareUltralight') {
throw new Error(
'[NFC Read] [ERR] Mifare technology could not be requested',
);
}
// 1. Get NFC Tag information
const nfcTag = await NfcManager.getTag()
console.log('[NFC Read] [INFO] Tag: ', nfcTag);
// 1. Get NFC Tag information
const nfcTag = await NfcManager.getTag();
console.log('[NFC Read] [INFO] Tag: ', nfcTag);
// 2. Read pages
const readLength = 60;
let mifarePages = [];
const mifarePagesRead = await Promise.all([...Array(readLength).keys()].map(async (_, i) => {
const pageOffset = i * 4; // 4 Pages are read at once, so offset should be in steps with length 4
let pages = await NfcManager.mifareUltralightHandlerAndroid.mifareUltralightReadPages(pageOffset);
mifarePages.push(pages);
console.log(`[NFC Read] [INFO] Mifare Page: ${pageOffset}`, pages);
//await wait(500); // If Mifare Chip is to slow
}));
// 2. Read pages
const readLength = 60;
let mifarePages = [];
const mifarePagesRead = await Promise.all(
[...Array(readLength).keys()].map(async (_, i) => {
const pageOffset = i * 4; // 4 Pages are read at once, so offset should be in steps with length 4
let pages = await NfcManager.mifareUltralightHandlerAndroid.mifareUltralightReadPages(
pageOffset,
);
mifarePages.push(pages);
console.log(`[NFC Read] [INFO] Mifare Page: ${pageOffset}`, pages);
//await wait(500); // If Mifare Chip is to slow
}),
);
// 3. Success
console.log('[NFC Read] [INFO] Success reading Mifare');
// 3. Success
console.log('[NFC Read] [INFO] Success reading Mifare');
// 4. Cleanup
_cleanup();
// 4. Cleanup
_cleanup();
} catch (ex) {
console.warn('[NFC Read] [ERR] Failed Reading Mifare: ', ex);
_cleanup();
console.warn('[NFC Read] [ERR] Failed Reading Mifare: ', ex);
_cleanup();
}
};
}
function _cleanup() {
NfcManager.cancelTechnologyRequest().catch(() => 0);
};
NfcManager.cancelTechnologyRequest().catch(() => 0);
}
```
To see more examples, please see [React Native NFC ReWriter App](https://github.com/revtel/react-native-nfc-rewriter)
@ -252,3 +259,4 @@ The plugin provides props for extra customization. Every time you change the pro
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB