@npaw/forge-react-native
v10.8.0
Published
NPAW Forge analytics for React Native: New Architecture TurboModule facade over the native Forge Android/Apple SDKs.
Readme
@npaw/forge-react-native
NPAW Forge analytics for React Native: application sessions, user identity, video and ad analytics, capture, and network observation, powered by the shared Forge analytics core through the native Android and Apple SDKs.
Use of this package requires an active NPAW commercial agreement. See LICENSE.
Install
npm install @npaw/forge-react-nativeRequires React Native 0.75+ with the New Architecture enabled (TurboModules).
iOS
cd ios && pod installThe default pod is IMA-free. For an app-owned native Google IMA integration,
opt in in ios/Podfile (iOS/tvOS 15+), then run pod install again:
# Replace the template's platform line so the app target keeps the higher of
# React Native's floor (min_ios_version_supported) and 15.0.
platform :ios, [Gem::Version.new(min_ios_version_supported), Gem::Version.new('15.0')].max.to_s
# Inside the application target:
pod 'NPAWForgeReactNative/IMAAdapter', :path => '../node_modules/@npaw/forge-react-native'
pod 'NPAWForgeReactNativeVideo/IMAAdapter', :path => '../node_modules/@npaw/forge-react-native-video'Do not hardcode '15.0': React Native 0.79 requires iOS 15.1, and a lower app
target fails the build. For a tvOS target apply the same rule to
platform :tvos: the higher of 15.0 and your react-native-tvos floor.
CocoaPods does not raise the application target automatically from a pod
subspec.
The two subspecs share the bundled Forge Core; do not add a separate
NPAWForgeApple/Core to the same application. The video subspec is needed
when the @npaw/forge-react-native-video package is installed so both Swift
targets use the IMA adapter's iOS/tvOS 15+ floor.
Android
The module depends on the published Forge Android artifacts. Two host-app settings are required:
Declare the NPAW Maven repository in the root
android/build.gradle. The repository the module declares for itself does not reach your app's dependency resolution, so without it the first build fails withCould not find com.npaw.forge:forge-android-core:allprojects { repositories { maven { url 'https://artifact.plugin.npaw.com/artifactory/plugins/android' } } }With
dependencyResolutionManagementinsettings.gradle, add the samemaven { url ... }entry there instead. With Expo, the config plugin adds it during prebuild.Compile against Android API 35 or newer (
compileSdkVersion = 35in theextblock of the rootandroid/build.gradle). The Forge artifacts declare that floor in their AAR metadata, so a lower value failscheckReleaseAarMetadata.
To report the device's connection type, also declare the normal
android.permission.ACCESS_NETWORK_STATE permission in your app manifest;
without it Android reports none.
Usage
import { NPAWForge } from '@npaw/forge-react-native';
const forge = await NPAWForge.create('<account-code>', {
appName: 'My App',
appReleaseVersion: '1.0.0',
});
await forge.startSession({ screen: 'Home' });Player adapters
This package reports application sessions and manual video/ad events. For
automatic playback reporting with react-native-video, add
@npaw/forge-react-native-video.
Documentation
Integration guides and the API reference are published at npaw.com.
