The eitri-bifrost is the bridge to interact with device and Eitri platform APIs. It's a library that makes those APIs available to eitri-apps. Functionalities such as navigation and access to other device resources can be accessed through this library.
To use the library's resources, simply import it into a .js file.
import Eitri from "eitri-bifrost";
The eitri-bifrost works in conjunction with another component of Eitri technology called eitri-machine.
The eitri-machine is a set of libraries that are installed in the main application and create the environment for eitri-apps to run. They are: eitri-android, eitri-ios, and react-native-eitri.
Eitri uses two mechanisms to control feature availability:
It is important for an eitri-app developer to understand both mechanisms and handle them properly to ensure secure code and the best experience for each client.
This concept is similar to others seen in technologies like browsers and in operating systems like Android and iOS. Example: MDN - Browser Support or caniuse.
Some functionalities depend directly on the version of eitri-machine installed in the main app. Given that some users do not automatically update their devices, it is possible that a client is running an older version of eitri-machine without support for a particular functionality.
Throughout the documentation, you will see in each method a description of which API_LEVEL is required to use it. With this information, you can perform an availability check as shown below:
// method definition: canIUse(apiLevel: number) : boolean
if (Eitri.canIUse(3)) {
const value = await Eitri.exampleNamespace.exampleMethod()
// ...
} else {
// handle or implement different code for older eitri-machine versions
}
Some features are distributed as optional modules that must be installed in the host application. These modules can be updated independently of the eitri-machine core.
Examples of module-based features:
eitri-ios-geolocation or eitri-android-geolocationTo check if a module is available, use the modules() method:
const modules = await Eitri.modules();
if (modules?.geolocation) {
// Geolocation module is available
const location = await Eitri.geolocation.getCurrentLocation();
} else {
// Module not installed - provide fallback or inform user
}
You can also check for specific methods within a module:
const modules = await Eitri.modules();
if (modules?.geolocation?.getCurrentLocation) {
// Method is available
const location = await Eitri.geolocation.getCurrentLocation();
}
Eitri.modules() once and reuse the result to avoid redundant checksGenerated using TypeDoc