PNLight SDK - Flutter Plugin

pub package

A Flutter plugin that provides iOS integration with the PNLight SDK, enabling comprehensive app analytics, purchase tracking, and device motion monitoring.

Features

  • 🚀 Easy iOS SDK integration for Flutter apps
  • 📊 Automatic app start and first install tracking
  • 💳 In-app purchase validation and tracking
  • 📱 Device motion and orientation monitoring
  • 🎯 Custom event logging with parameters
  • 🔒 Privacy-compliant IDFA collection (with user consent)
  • 📈 Real-time analytics and reporting

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  pnlight_sdk: ^0.1.0

Then run:

flutter pub get

iOS Setup

  1. Add the required frameworks to your iOS project in Xcode:

    • StoreKit.framework
    • CoreMotion.framework
    • AdSupport.framework
    • AppTrackingTransparency.framework (iOS 14.0+)
  2. For iOS 14.0+ apps that need IDFA tracking, add the NSUserTrackingUsageDescription key to your Info.plist:

<key>NSUserTrackingUsageDescription</key>
<string>This app uses device tracking to provide personalized analytics and improve user experience.</string>

Usage

Initialize the SDK

Initialize the PNLight SDK with your API key in your app's main function:

import 'package:pnlight_sdk/pnlight_sdk.dart';

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

  // Initialize PNLight SDK
  await PNLightSDK.initialize('YOUR_API_KEY_HERE');

  runApp(MyApp());
}

Validate Purchases

Automatically validate in-app purchases:

bool isValid = await PNLightSDK.validatePurchase(); // captcha defaults to true
// Or disable captcha: bool isValid = await PNLightSDK.validatePurchase(captcha: false);
// Handle validation result

Log Custom Events

Track custom events with optional parameters:

// Simple event
await PNLightSDK.logEvent('button_tapped');

// Event with parameters
await PNLightSDK.logEvent('purchase_completed', {
  'product_id': 'premium_subscription',
  'amount': 9.99,
  'currency': 'USD',
});

Platform Support

  • ✅ iOS 12.0+
  • ❌ Android (iOS only SDK)

Requirements

  • Flutter: >=3.3.0
  • Dart: >=2.17.0 <4.0.0
  • iOS: 12.0+

License

This plugin wraps the PNLight SDK. Please refer to the PNLight website for licensing information.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For support and questions, visit pnlight.app or create an issue in this repository.

Libraries

pnlight_sdk