react-native-noke
Getting started
$ npm install react-native-noke --save
or
$ yarn add react-native-noke
or latest version
$ yarn add git+git+https://github.com/Ant-Tech-Agency/react-native-noke.git
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-noke
and addRNNoke.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNNoke.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)< - Add empty file Test.swift in main project
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.lynkxyz.noke.RNNokePackage;
to the imports at the top of the file - Add
new RNNokePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-noke' project(':react-native-noke').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-noke/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-noke')
- After adding the dependency to your Android Manifest
<service android:name="com.noke.nokemobilelibrary.NokeDeviceManagerService" android:enabled="true"/>
Usage
;RNNoke interface NokeData name?: string key?: string command?: string macAddress: string interface NokeCommandsData macAddress: string commands: string interface NokeResponse name: string mac: string session: string status: boolean interface NokeInfoResponse name: string battery: number mac: string offlineKey: string offlineUnlockCmd: string serial: string session: string trackingKey: string lastSeen: number version: string type EventName = 'onServiceConnected' | // only Android 'onServiceDisconnected' | // only Android 'onNokeDiscovered' | 'onNokeConnecting' | 'onNokeConnected' | 'onNokeSyncing' | 'onNokeUnlocked' | 'onNokeDisconnected' | 'onBluetoothStatusChanged' | 'onError' interface RNNoke Promise<status: boolean> Promise<status: boolean> Promise<status: boolean> Promise<NokeResponse> Promise<NokeResponse> Promise<null> Promise<null> Promise<NokeResponse> Promise<NokeInfoResponse> Promise<null> on: eventName: EventName void RNNoke Observable<name: EventName data: NokeResponse> { this // only Android RNNoke // only Android // only Android } { ifPlatformOS === 'ios' return return PermissionsAndroid } { RNNoke } { RNNoke } { RNNoke } { RNNoke } { RNNoke } { RNNoke } { RNNoke } { return <View style=stylescontainer> <Button onPress=thisonSendCommands title="Unlock noke by commands" /> <Button onPress=thisonUnlock title="Unlock noke offline" /> <Button onPress=thisonAddNoke title="Add noke" /> <Button onPress=thisonRemoveAllNokes title="Remove noke" /> </View> }
License
react-native-noke is available under the Apache 2.0 license. See the LICENSE file for more info.
Copyright © 2018 Ant-Tech Ltd. All rights reserved.