$ npm install @monoku/react-native-magtek --save
$ react-native link @monoku/react-native-magtek
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜@monoku/react-native-magtek
and addRNMagtek.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNMagtek.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNMagtekPackage;
to the imports at the top of the file - Add
new RNMagtekPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-magtek' project(':react-native-magtek').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-magtek/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-magtek')
- In Visual Studio add the
RNMagtek.sln
innode_modules/react-native-magtek/windows/RNMagtek.sln
folder to their solution, reference from their app. - Open up your
MainPage.cs
app
- Add
using Magtek.RNMagtek;
to the usings at the top of the file - Add
new RNMagtekPackage()
to theList<IReactPackage>
returned by thePackages
method
import RNMagtek, { RNMagtekEventsEmitter } from '@monoku/react-native-magtek';
RNMagtek.connect((data) => {
const { isDeviceConnected, isDeviceOpened } = data;
if (isDeviceConnected && isDeviceOpened) {
console.log("Card reader is connected and ready!!!");
}
});
RNMagtekEventsEmitter.addListener('devConnectionNotification', (data) => {
const { isDeviceConnected } = data;
if (!isDeviceConnected) {
console.log("Opps! Device have been disconnected.");
}
});