@pnlight/sdk-react-native 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PNLightSDK-ReactNative.podspec +1 -1
- package/README.md +83 -0
- package/ios/PNLightSDK.m +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# PNLight SDK - React Native
|
|
2
|
+
|
|
3
|
+
A React Native wrapper for the PNLight SDK.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the package using npm or yarn:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @pnlight/sdk-react-native
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @pnlight/sdk-react-native
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For iOS, don't forget to install CocoaPods dependencies:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
cd ios && pod install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
import PNLightSDK from '@pnlight/sdk-react-native';
|
|
29
|
+
|
|
30
|
+
// 1. Initialize the SDK (do this first)
|
|
31
|
+
await PNLightSDK.initialize('your-api-key');
|
|
32
|
+
|
|
33
|
+
// 2. Validate a purchase (call before purchase - if false, don't proceed)
|
|
34
|
+
const isValidPurchase = await PNLightSDK.validatePurchase();
|
|
35
|
+
console.log('Purchase validation result:', isValidPurchase);
|
|
36
|
+
|
|
37
|
+
// 3. Log an event (example: user completed a tutorial)
|
|
38
|
+
await PNLightSDK.logEvent('tutorial_completed', {
|
|
39
|
+
level: '1',
|
|
40
|
+
duration: '300',
|
|
41
|
+
success: 'true'
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Important Notes
|
|
46
|
+
|
|
47
|
+
- **Initialization**: Always initialize the SDK first before using any other methods
|
|
48
|
+
- **Purchase Validation**: Call `validatePurchase()` before allowing a purchase. If it returns `false`, it's better not to proceed with the purchase
|
|
49
|
+
- **Event Logging**: Use `logEvent()` to log events to the PNLight platform for analytics and tracking
|
|
50
|
+
|
|
51
|
+
## API Reference
|
|
52
|
+
|
|
53
|
+
### `PNLightSDK`
|
|
54
|
+
|
|
55
|
+
The main SDK module.
|
|
56
|
+
|
|
57
|
+
#### Methods
|
|
58
|
+
|
|
59
|
+
- `initialize(apiKey: string): Promise<void>` - Initialize the SDK with your API key
|
|
60
|
+
- `validatePurchase(captcha: boolean = true): Promise<boolean>` - Validate a purchase with anti-bot protection. Set captcha to false to skip captcha challenge.
|
|
61
|
+
- `logEvent(eventName: string, eventArgs?: object): Promise<void>` - Log a custom event
|
|
62
|
+
|
|
63
|
+
## Platform Setup
|
|
64
|
+
|
|
65
|
+
### iOS
|
|
66
|
+
|
|
67
|
+
The SDK requires the following frameworks to be linked (usually handled automatically):
|
|
68
|
+
- **AppTrackingTransparency.framework**
|
|
69
|
+
- **AdSupport.framework**
|
|
70
|
+
- **StoreKit.framework**
|
|
71
|
+
- **CoreMotion.framework**
|
|
72
|
+
|
|
73
|
+
Add the following to your `Info.plist`:
|
|
74
|
+
|
|
75
|
+
```xml
|
|
76
|
+
<key>NSUserTrackingUsageDescription</key>
|
|
77
|
+
<string>This identifier will be used to deliver personalized ads to you.</string>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Android
|
|
81
|
+
|
|
82
|
+
Make sure your `minSdkVersion` is set to at least 21 in `android/build.gradle`.
|
|
83
|
+
|
package/ios/PNLightSDK.m
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
@interface RCT_EXTERN_MODULE(PNLightRN, NSObject)
|
|
5
5
|
RCT_EXTERN_METHOD(initialize:(NSString *)apiKey resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
6
|
-
RCT_EXTERN_METHOD(validatePurchase:(BOOL)captcha
|
|
6
|
+
RCT_EXTERN_METHOD(validatePurchase:(BOOL)captcha resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
7
7
|
RCT_EXTERN_METHOD(logEvent:(NSString *)eventName eventArgs:(NSDictionary *)eventArgs resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
8
8
|
@end
|
|
9
9
|
|