Skip to main content
Use @pnlight/sdk-react-native for React Native apps that need PNLight on iOS.

Install

npm install @pnlight/sdk-react-native
Package page: @pnlight/sdk-react-native on npm. React Native SDK version

Initialize the SDK

Call initialize once during app startup.
import { initialize } from "@pnlight/sdk-react-native";

await initialize("pnlight_sdk_token");

Common calls

import {
  addAttribution,
  getUserId,
  logEvent,
} from "@pnlight/sdk-react-native";

const userId = await getUserId();

await addAttribution(
  "appsFlyer",
  { af_status: "Non-organic" },
  "appsFlyerCustomerId"
);

await logEvent("paywall_viewed", {
  placement: "paywall",
});
logEvent sends optional in-app events to PNLight. You can review them in Analytics → App Events, on the Events page, and in customer timelines.

IDFA after ATT

If PNLight initializes before the App Tracking Transparency prompt completes, call updateIdfa() after authorization so PNLight receives the granted IDFA.
import { updateIdfa } from "@pnlight/sdk-react-native";
import { requestTrackingPermission } from "react-native-tracking-transparency";

await requestTrackingPermission();
await updateIdfa();

Remote UI component

Use RemoteUiView to fetch and render a placement. Add an onAction handler so your app can respond to actions from the returned UI.
import { RemoteUiView } from "@pnlight/sdk-react-native";

export function PaywallScreen() {
  return (
    <RemoteUiView
      placement="paywall"
      cardId="paywall_card"
      style={{ flex: 1 }}
      onAction={(event) => {
        if (event.logId === "purchase_button") {
          startPurchase(event.params.id).then(() => {
            navigation.navigate("Main");
          });
        }
      }}
    />
  );
}

Remote UI props

PropTypeDescription
placementstringPlacement ID configured in PNLight.
cardIdstringOptional card ID. Defaults to a placement-based value.
securebooleanDeprecated. Secure rendering is controlled by the dashboard placement.
preventRecordingbooleanDeprecated. Capture blocking is controlled by the dashboard placement.
attributionRequiredbooleanWaits for attribution before returning a config when enabled. Defaults to true.
ignoreCachebooleanWaits for a fresh server response instead of serving a cached config. Defaults to false.
onActionfunctionHandles custom actions from the rendered UI.
onErrorfunctionHandles config loading errors.
Use Remote UI to learn how placements and actions work.