@pnlight/sdk-react-native
v0.3.8
Published
React Native wrapper for PNLight iOS binary SDK
Readme
PNLight SDK - React Native
A React Native wrapper for the PNLight SDK.
Installation
Install the package using npm or yarn:
npm install @pnlight/sdk-react-nativeor
yarn add @pnlight/sdk-react-nativeFor iOS, don't forget to install CocoaPods dependencies:
cd ios && pod installUsage
import PNLightSDK from '@pnlight/sdk-react-native';
// 1. Initialize the SDK (do this first)
await PNLightSDK.initialize('your-api-key');
// 2. Validate a purchase (call before purchase - if false, don't proceed)
const isValidPurchase = await PNLightSDK.validatePurchase();
console.log('Purchase validation result:', isValidPurchase);
// 3. Log an event (example: user completed a tutorial)
await PNLightSDK.logEvent('tutorial_completed', {
level: '1',
duration: '300',
success: 'true'
});Important Notes
- Initialization: Always initialize the SDK first before using any other methods
- Purchase Validation: Call
validatePurchase()before allowing a purchase. If it returnsfalse, it's better not to proceed with the purchase - Event Logging: Use
logEvent()to log events to the PNLight platform for analytics and tracking
API Reference
PNLightSDK
The main SDK module.
Methods
initialize(apiKey: string): Promise<void>- Initialize the SDK with your API keyvalidatePurchase(captcha: boolean = true): Promise<boolean>- Validate a purchase with anti-bot protection. Set captcha to false to skip captcha challenge.logEvent(eventName: string, eventArgs?: object): Promise<void>- Log a custom event
Platform Setup
iOS
The SDK requires the following frameworks to be linked (usually handled automatically):
- AppTrackingTransparency.framework
- AdSupport.framework
- StoreKit.framework
- CoreMotion.framework
Add the following to your Info.plist:
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>Android
Make sure your minSdkVersion is set to at least 21 in android/build.gradle.
