eitri-bifrost

API for eitri-apps

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.

Operation

To use the library's resources, simply import it into a .js file.

import Eitri from "eitri-bifrost";

Compatibility Control

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:

  1. API_LEVEL: Core features tied to eitri-machine version
  2. Modules: Optional features installed as separate modules

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.

API_LEVEL-Based Features

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
}

Module-Based Features

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:

  • Geolocation: Requires eitri-ios-geolocation or eitri-android-geolocation

To 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();
}

Best Practices

  • Monitor adoption: Use your Eitri console to track API_LEVEL and module adoption in your app's installed base
  • Graceful degradation: Always provide fallbacks or clear messaging when features are unavailable
  • Cache module checks: Call Eitri.modules() once and reuse the result to avoid redundant checks
  • Documentation: Each method's documentation indicates whether it requires an API_LEVEL, a module, or both

Capabilities

Documentation of available methods

Generated using TypeDoc