@pnlight/sdk-react-native 0.3.0 → 0.3.2
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/PNLight.xcframework/ios-arm64/PNLight.framework/Info.plist +0 -0
- package/PNLight.xcframework/ios-arm64/PNLight.framework/Modules/PNLight.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/PNLight.xcframework/ios-arm64_x86_64-simulator/PNLight.framework/Info.plist +0 -0
- package/PNLight.xcframework/ios-arm64_x86_64-simulator/PNLight.framework/Modules/PNLight.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/PNLight.xcframework/ios-arm64_x86_64-simulator/PNLight.framework/Modules/PNLight.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/PNLightSDK-ReactNative.podspec +1 -1
- package/ios/PNLightSDK.swift +35 -23
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/ios/PNLightSDK.swift
CHANGED
|
@@ -1,29 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import Flutter
|
|
2
|
+
import UIKit
|
|
3
3
|
import PNLight
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
resolve(nil)
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@objc func validatePurchase(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
15
|
-
Task {
|
|
16
|
-
let result = await PNLightSDK.shared.validatePurchase()
|
|
17
|
-
resolve(result)
|
|
18
|
-
}
|
|
5
|
+
public class PNLightFlutterPlugin: NSObject, FlutterPlugin {
|
|
6
|
+
public static func register(with registrar: FlutterPluginRegistrar) {
|
|
7
|
+
let channel = FlutterMethodChannel(name: "pnlight_sdk", binaryMessenger: registrar.messenger())
|
|
8
|
+
let instance = PNLightFlutterPlugin()
|
|
9
|
+
registrar.addMethodCallDelegate(instance, channel: channel)
|
|
19
10
|
}
|
|
20
11
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) async {
|
|
13
|
+
switch call.method {
|
|
14
|
+
case "initialize":
|
|
15
|
+
if let args = call.arguments as? [String: Any], let apiKey = args["apiKey"] as? String {
|
|
16
|
+
await PNLightSDK.shared.initialize(apiKey: apiKey)
|
|
17
|
+
result(nil)
|
|
18
|
+
} else {
|
|
19
|
+
result(FlutterError(code: "ARG_ERROR", message: "apiKey missing", details: nil))
|
|
20
|
+
}
|
|
21
|
+
case "validatePurchase":
|
|
22
|
+
Task {
|
|
23
|
+
let ok = await PNLightSDK.shared.validatePurchase()
|
|
24
|
+
result(ok)
|
|
25
|
+
}
|
|
26
|
+
case "logEvent":
|
|
27
|
+
if let args = call.arguments as? [String: Any],
|
|
28
|
+
let eventName = args["eventName"] as? String {
|
|
29
|
+
let eventArgs = args["eventArgs"] as? [String: Any]
|
|
30
|
+
Task {
|
|
31
|
+
await PNLightSDK.shared.logEvent(eventName, eventArgs: eventArgs)
|
|
32
|
+
result(nil)
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
result(FlutterError(code: "ARG_ERROR", message: "eventName missing", details: nil))
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
result(FlutterMethodNotImplemented)
|
|
25
39
|
}
|
|
26
40
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
}
|