Skip to main content

Introduction

This document describes how to integrate the B2Metric React Native SDK into a mobile application. The SDK lets your app capture product analytics events, manage sessions automatically, and report push notification activity, all with a single JavaScript / TypeScript API that works identically on iOS and Android.

It is intended for mobile engineering teams that are familiar with React Native development, JavaScript or TypeScript, and the standard iOS and Android toolchains. No analytics-specific background is required — the relevant concepts are explained as they appear.

What the SDK Does for You

Once initialized, the SDK runs in the background and handles three responsibilities that you would otherwise have to build yourself:

  • Event collection. You call a single method logEvent to record any user action that matters to your product. The SDK batches events efficiently and sends them to the B2Metric backend over HTTPS.
  • Session and lifecycle tracking. The SDK automatically emits three lifecycle events: first_open on first launch, session_start when a session begins, and session_end when it concludes. You do not need to wire these up manually.
  • Push notification reporting. The SDK provides helper methods to register push tokens (FCM, HMS, APNS) and to report when a user opens the app from a notification tap.

What You Remain Responsible For

The SDK does not capture screen views, button taps, or any other UI events by itself — you decide what counts as an event in your product. It also does not request push notification permissions or display notifications; that remains the responsibility of your existing notification stack (typically Firebase Messaging or a similar library). The SDK only registers the token with B2Metric so that your B2Metric campaigns can target the device.

Requirements

Before starting integration, confirm that your project meets the minimum platform and toolchain requirements below. The SDK is implemented as a TurboModule with native Kotlin (Android) and Objective-C (iOS) modules, so both platforms have a hard minimum version below which the SDK will not link.

RequirementMinimum versionNotes
React Native0.71Lower versions may compile but are not supported and not tested.
iOS deployment target13.0Set this in your Podfile and Xcode project settings.
Android minSdkVersion24Equivalent to Android 7.0 Nougat.
Node.js (build only)18 LTS or newerRequired by recent React Native CLI versions.
TypeScript (optional)4.5+The SDK ships its own type definitions; no DefinitelyTyped install is needed.

If your project predates React Native 0.71 or uses a deployment target older than iOS 13, you will need to upgrade those baselines before adding the SDK. Doing so first is strongly recommended over attempting workarounds — recent React Native versions also bring meaningful improvements in build performance and bridge stability that benefit any production app.