1.0.33 • Published 4 years ago
react-native-ul-pure v1.0.33
react-native-ul-pure
Getting started
$ npm install react-native-ul-pure@1.0.14 --save
Mostly automatic installation
Shared
$ react-native link react-native-ul-pure
Android
- Insert the following lines inside the allprojects repositories block in
android/build.gradle
:maven { url "https://dl.bintray.com/fluxloop/pure" }
- Inside
android/build.gradle
, change thecompileSdkVersion
andtargetSdkVersion
to29
. - Insert the following lines inside the dependencies block in
android/app/build.gradle
:implementation 'com.google.android.gms:play-services-location:17.0.0'
- Add the following permissions inside the
application
block inandroid/src/main/AndroidManifest.xml
:<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
iOS
$ cd ios && pod install
- Open your projects
.xcodeworkspace
in Xcode - In Xcode, in the project navigator, select your project.
- Add
libreact-native-ul-pure.a
andCoreLocation.framework
to your targetsFrameworks, Libraries, and Embedded Content
- Add
PureUL.framework
from../node_modules/react-native-ul-pure/ios/Frameworks
to your targetsFrameworks, Libraries, and Embedded Content
- In
Build Settings
of your target, disable bitcode underBuild Options
- In
Build settings
of your target, add$(PROJECT_DIR)/../node_modules/react-native-ul-pure/ios/Frameworks
asrecursive
toFramework Search Paths
- Add these keys and values in your applications
Info.plist
:
<key>NSMicrophoneUsageDescription</key>
<string>For å fange opp ultralyd til å beregne din posisjon innendørs på steder med ultralyd posisjonering.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>For å kunne skru av mikrofonen når du ikke er på et sted med ultralyd posisjonering.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>For å kunne skru av mikrofonen når du ikke er på et sted med ultralyd posisjonering.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>For å kunne skru av mikrofonen når du ikke er på et sted med ultralyd posisjonering.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>For å kunne skru av mikrofonen når du ikke er på et sted med ultralyd posisjonering.</string>
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.fluxloop2.UlPurePackage;
to the imports at the top of the file - Add
new UlPurePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-ul-pure' project(':react-native-ul-pure').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ul-pure/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-ul-pure')
- Follows steps 1 to 4 in mostly automatic installation > android
Usage
Import module:
import UlPure from 'react-native-ul-pure';
Start tracking:
UlPure.setClientData("UserId", ["employees"], "DisplayName", "status");
UlPure.startTracking();
Stop tracking:
UlPure.stopTracking();
Subscribing to events:
// Android
import { DeviceEventEmitter } from 'react-native';
import UlPure from 'react-native-ul-pure';
componentDidMount() {
UlPure.addOnLocationChangeListener();
UlPure.addOnZoneChangeListener();
UlPure.addOnLocationExitListener();
this.locationChangeListener = DeviceEventEmitter.addListener("ULLocationChange", locationChange => console.log(JSON.stringify(locationChange)));
this.zoneChangeListener = DeviceEventEmitter.addListener("ULZoneChange", zoneChange => console.log(JSON.stringify(zoneChange)));
this.locationExitListener = DeviceEventEmitter.addListener("ULLocationExit", () => { UlPure.stopTracking(); });
}
// iOS
import { NativeEventEmitter } from 'react-native';
import UlPure from 'react-native-ul-pure';
const pureEmitter = new NativeEventEmitter(UlPure)
var locationChangeSubscription = null;
var zoneChangeSubscription = null;
var onExitSubscription = null;
componentDidMount() {
UlPure.addOnLocationChangeListener();
UlPure.addOnZoneChangeListener();
UlPure.addOnLocationExitListener();
locationChangeSubscription = pureEmitter.addListener("ULLocationChange", (locationChange) => console.log(JSON.stringify(locationChange)));
zoneChangeSubscription = pureEmitter.addListener("ULZoneChange", (zoneChange) => console.log(JSON.stringify(zoneChange)));
onExitSubscription = pureEmitter.addListener("ULLocationExit", () => { UlPure.stopTracking(); });
}
Simulate location & zone change:
import UlPure from 'react-native-ul-pure';
componentDidMount() {
let locationId = "4bee5ffb-bbbb-46ba-ada2-1c828632a70c";
let floor = 4;
let latitude1 = 59.91368980471839;
let longitude1 = 10.74141233434014
let latitude2 = 59.91370626050136;
let longitude2 = 10.741587015014176;
UlPure.setClientData("UserId", ["employees"], "ReactNative", "available");
UlPure.simulateLocationChange(locationId, latitude1, longitude1, floor);
setTimeout(() => {
UlPure.simulateLocationChange(locationId, latitude2, longitude2, floor);
}, 2000);
}
LocationChange emits:
{
"appInstallationId": string,
"groups": [string],
"displayName": string,
"status": string,
"timestamp": double,
"alt": float,
"lat": double,
"lng": double,
"floor": int
}
ZoneChange emits:
Zone:
{
"id": string,
"externalId": string,
"tags": [string],
"venue": {
"id": string,
"externalId": string,
"tags": [string]
}
}
ZoneChange:
{
"current": {
"zone": Zone,
"duration": Long
},
"previous": {
"zone": Zone,
"duration": Long
}
}
1.0.33
4 years ago
1.0.32
4 years ago
1.0.31
4 years ago
1.0.29
4 years ago
1.0.28
4 years ago
1.0.30
4 years ago
1.0.26
4 years ago
1.0.27
4 years ago
1.0.25
4 years ago
1.0.24
4 years ago
1.0.23
4 years ago
1.0.22
5 years ago
1.0.21
5 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago