/react-native-ito

A privacy-first contact tracing library for React Native apps

Primary LanguageJavaOtherNOASSERTION

ito library for React Native apps

Documentation License

What it does

This library is the native backend for the ito app. It does several things

  • generate TCNs (Temporary Contact Numbers) as per the STRICT protocol
  • handle bluetooth communication
  • store the data received over bluetooth
  • store the data used to generate the TCNs
  • regularly poll the server for TCN reports and compare with the local database
  • upload TCN generation data from specified timeframes
  • provide some feedback for better UX

Getting started

$ npm install https://github.com/ito-org/react-native-ito --save

Mostly automatic installation

$ react-native link react-native-ito

Usage

Retrieve the native module.

import {NativeModules, NativeEventEmitter} from 'react-native';

const { ItoBluetooth } = NativeModules;

Start tracing (after getting location permission for Bluetooth advertising and scanning):

ItoBluetooth.restartTracing();

Get the current and recent distances of ito devices in the vicinity.

const eventEmitter = new NativeEventEmitter(ItoBluetooth);
this.eventListener = eventEmitter.addListener('onDistancesChanged', (distances) => {
  //get notified about the distances to nearby devices
});

Find out whether the user is likely to have been in contact with an infected user

ItoBluetooth.isPossiblyInfected() // boolean

Upload the user's own TCNs of the last 7 days

const nowSeconds = Date.now() / 1000;
const sevenDaysAgo = nowSeconds - 7 * 24 * 60 * 60;
ItoBluetooth.publishBeaconUUIDs(
  sevenDaysAgo,
  now,
  (success) => {
    console.log('upload ' + success ? 'succeeded' : 'failed');
  },
)