Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
/ react-native-ito Public archive

A privacy-first contact tracing library for React Native apps

License

Notifications You must be signed in to change notification settings

ito-org/react-native-ito

Repository files navigation

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');
  },
)