Skip to content

OpenStopCovid/react-native-dp3t

 
 

Repository files navigation

react-native-dp3t

DP3T native bindings for React Native.

Status

Pre-alpha. Requires some manual setup to work. Not tested yet. Can change without notice.

The iOS SDK and Android SDK themselves are in alpha state.

This project is bootstraped from bob, see implementation notes.

Installation

Right now you need to clone it or add it with its Git URL, and build it with yarn bootstrap.

```sh npm install react-native-dp3t ```

This lib does not work on emulators or simulators, and will crash or burn incomprehensibly. Run on physical devices.

Necessary manual Android setup

Customize the tracing notification as in the Android SDK

You have to make changes in build.gradle:

  • minSdkVersion to 23 or above, as the Android DP3T SDK dos not support lower versions.
  • compileSdkVersion to 29 or above, to fulfill the requirement for android:foregroundServiceType in Android Q (set by the Android DP3T SDK).

The lib automatically sets the android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission. The lib also ask the user to add your app to the battery optimization whitelist for you when you call Dp3t.init().

The Play Store usually prohibits this, so you need to make sure the Play Store filing explains why this is necessary. This may only be necessary until the Android SDK uses official Google DP3T support, in which case we will adapt the permissions & warnings in this section.

Necessary manual iOS setup

Minimum iOS version is 11 for DP3T iOS SDK, so you need to change the verison to (at least) 11.0 in your iOS Podfile.

You have to add the react-native-swift package and run react-native swiftify and run pod install again, because this native module (and the DP3T iOS SDK) use Swift.

Add bluetooth capabilities to your Info.plist file.

Add background fetch configuration to your Info.plist file.

You have to add pod 'DP3TSDK', :git => "https://github.com/DP-3T/dp3t-sdk-ios.git", :commit => 'COMMIT_ID'' in your Podfile until the SDK stabilizes, and a version is pushed on the Pods repo. Replace COMMIT_ID with 13c009500dccd1488131a6b0c8ae69247b33a9b0 (latest version supported, watch this file to follow the changes)

This implementation does not yet support requesting the permissions to use Bluetooth in iOS.

iOS SDK does not sync keys automatically. These bindings do not attempt to sync automatically either: you need to call Dp3t.sync() manually.

Usage

import Dp3t from 'react-native-dp3t';

// ...

const deviceName = await Dp3t.getDeviceName();

Testing / Contributing

License

MIT

Alternatives

Wix incubator is building a RN lib from scratch (they don't use DP3T SDK)

About

React Native bindings for DP3T SDK (iOS + Andoid)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 53.0%
  • Swift 14.1%
  • Kotlin 13.9%
  • Objective-C 7.1%
  • Ruby 5.5%
  • Java 4.6%
  • JavaScript 1.8%