Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.pnlight.app/llms.txt

Use this file to discover all available pages before exploring further.

Use pnlight_sdk for Flutter apps that need PNLight on iOS.

Requirements

  • Flutter 3.3.0+
  • Dart 2.17.0 or later, below 4.0.0
  • iOS 12.0+

Install

Add the package to pubspec.yaml:
dependencies:
  pnlight_sdk: ^0.6.3
Then run:
flutter pub get

iOS setup

If you use RemoteUiView, add the DivKit CocoaPods source to ios/Podfile before other sources:
source 'https://github.com/divkit/divkit-ios.git'
If your app collects IDFA on iOS 14.0+, add NSUserTrackingUsageDescription to Info.plist:
<key>NSUserTrackingUsageDescription</key>
<string>This app uses device tracking to support attribution and analytics.</string>

Initialize the SDK

import 'package:pnlight_sdk/pnlight_sdk.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await PNLightSDK.initialize('pnlight_sdk_token');

  runApp(const MyApp());
}

Common calls

final isAllowed = await PNLightSDK.validatePurchase();

await PNLightSDK.logEvent('purchase_completed', {
  'product_id': 'premium_subscription',
  'amount': 9.99,
});

Server-driven UI

import 'package:pnlight_sdk/pnlight_sdk.dart';

RemoteUiView(
  placement: 'paywall',
  cardId: 'paywall_card',
  onAction: (RemoteUiActionEvent event) {
    if (event.path == 'purchase') {
      startPurchase(event.params['id']);
    }
  },
)
The Flutter package wraps the PNLight iOS SDK. Do not call PNLight SDK methods on unsupported platforms.