@virex-tech/paywallo-sdk 1.3.0 → 1.4.0
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/PaywalloSdk.podspec +1 -0
- package/README.md +28 -53
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/paywallo/sdk/PaywalloFBBridgeModule.kt +84 -0
- package/android/src/main/java/com/paywallo/sdk/PaywalloSdkPackage.kt +4 -1
- package/dist/index.d.mts +13 -10
- package/dist/index.d.ts +13 -10
- package/dist/index.js +283 -164
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +273 -149
- package/dist/index.mjs.map +1 -1
- package/ios/PaywalloFBBridge.m +23 -0
- package/ios/PaywalloFBBridge.swift +77 -0
- package/ios/PaywalloStoreKit.swift +0 -4
- package/ios/RCTBridgeTypes.swift +6 -0
- package/package.json +5 -19
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
|
|
3
|
+
@interface RCT_EXTERN_MODULE(PaywalloFBBridge, NSObject)
|
|
4
|
+
|
|
5
|
+
RCT_EXTERN_METHOD(getAnonymousID:(RCTPromiseResolveBlock)resolve
|
|
6
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
7
|
+
|
|
8
|
+
RCT_EXTERN_METHOD(logEvent:(NSString *)name
|
|
9
|
+
params:(NSDictionary *)params
|
|
10
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
11
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
12
|
+
|
|
13
|
+
RCT_EXTERN_METHOD(logPurchase:(double)amount
|
|
14
|
+
currency:(NSString *)currency
|
|
15
|
+
params:(NSDictionary *)params
|
|
16
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
17
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
18
|
+
|
|
19
|
+
RCT_EXTERN_METHOD(setUserID:(NSString *)userId)
|
|
20
|
+
|
|
21
|
+
RCT_EXTERN_METHOD(flush)
|
|
22
|
+
|
|
23
|
+
@end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import FBSDKCoreKit
|
|
3
|
+
|
|
4
|
+
@objc(PaywalloFBBridge)
|
|
5
|
+
class PaywalloFBBridge: NSObject {
|
|
6
|
+
|
|
7
|
+
// MARK: - Anonymous ID
|
|
8
|
+
|
|
9
|
+
@objc
|
|
10
|
+
func getAnonymousID(
|
|
11
|
+
_ resolve: @escaping RCTPromiseResolveBlock,
|
|
12
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
13
|
+
) {
|
|
14
|
+
let id = AppEvents.shared.anonymousID
|
|
15
|
+
guard let id = id, !id.isEmpty else {
|
|
16
|
+
resolve(nil)
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
resolve(id)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// MARK: - Log Event
|
|
23
|
+
|
|
24
|
+
@objc
|
|
25
|
+
func logEvent(
|
|
26
|
+
_ name: String,
|
|
27
|
+
params: NSDictionary,
|
|
28
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
29
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
30
|
+
) {
|
|
31
|
+
let parameters = params.reduce(into: [AppEvents.ParameterName: Any]()) { acc, pair in
|
|
32
|
+
if let key = pair.key as? String {
|
|
33
|
+
acc[AppEvents.ParameterName(key)] = pair.value
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
AppEvents.shared.logEvent(AppEvents.Name(name), parameters: parameters)
|
|
37
|
+
resolve(nil)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// MARK: - Log Purchase
|
|
41
|
+
|
|
42
|
+
@objc
|
|
43
|
+
func logPurchase(
|
|
44
|
+
_ amount: Double,
|
|
45
|
+
currency: String,
|
|
46
|
+
params: NSDictionary,
|
|
47
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
48
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
49
|
+
) {
|
|
50
|
+
let parameters = params.reduce(into: [AppEvents.ParameterName: Any]()) { acc, pair in
|
|
51
|
+
if let key = pair.key as? String {
|
|
52
|
+
acc[AppEvents.ParameterName(key)] = pair.value
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
AppEvents.shared.logPurchase(amount: amount, currency: currency, parameters: parameters)
|
|
56
|
+
resolve(nil)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// MARK: - Set User ID
|
|
60
|
+
|
|
61
|
+
@objc
|
|
62
|
+
func setUserID(_ userId: String) {
|
|
63
|
+
AppEvents.shared.userID = userId
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// MARK: - Flush
|
|
67
|
+
|
|
68
|
+
@objc
|
|
69
|
+
func flush() {
|
|
70
|
+
AppEvents.shared.flush()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@objc
|
|
74
|
+
static func requiresMainQueueSetup() -> Bool {
|
|
75
|
+
return false
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import StoreKit
|
|
3
3
|
|
|
4
|
-
// React Native bridge types — avoids need for bridging header
|
|
5
|
-
typealias RCTPromiseResolveBlock = @convention(block) (Any?) -> Void
|
|
6
|
-
typealias RCTPromiseRejectBlock = @convention(block) (String?, String?, Error?) -> Void
|
|
7
|
-
|
|
8
4
|
@available(iOS 15.0, *)
|
|
9
5
|
@objc(PaywalloStoreKit)
|
|
10
6
|
class PaywalloStoreKit: NSObject {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
// React Native bridge types — shared across native modules
|
|
4
|
+
// Avoids need for bridging header
|
|
5
|
+
typealias RCTPromiseResolveBlock = @convention(block) (Any?) -> Void
|
|
6
|
+
typealias RCTPromiseRejectBlock = @convention(block) (String?, String?, Error?) -> Void
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virex-tech/paywallo-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "SDK React Native para integração com Paywallo - Paywalls, Subscriptions e Analytics",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -60,30 +60,16 @@
|
|
|
60
60
|
"engines": {
|
|
61
61
|
"node": ">=18.0.0"
|
|
62
62
|
},
|
|
63
|
-
"
|
|
63
|
+
"dependencies": {
|
|
64
64
|
"@react-native-async-storage/async-storage": ">=1.0.0",
|
|
65
|
-
"@react-native-community/netinfo": ">=9.0.0",
|
|
66
65
|
"expo-application": ">=5.0.0",
|
|
67
66
|
"expo-tracking-transparency": ">=0.5.0",
|
|
68
|
-
"react": ">=18.0.0 || >=19.0.0",
|
|
69
|
-
"react-native": ">=0.72.0",
|
|
70
67
|
"react-native-device-info": ">=10.0.0",
|
|
71
|
-
"react-native-fbsdk-next": ">=13.0.0",
|
|
72
68
|
"react-native-keychain": ">=8.0.0"
|
|
73
69
|
},
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
"react-native-keychain": {
|
|
79
|
-
"optional": true
|
|
80
|
-
},
|
|
81
|
-
"react-native-fbsdk-next": {
|
|
82
|
-
"optional": true
|
|
83
|
-
},
|
|
84
|
-
"expo-tracking-transparency": {
|
|
85
|
-
"optional": true
|
|
86
|
-
}
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"react": ">=18.0.0 || >=19.0.0",
|
|
72
|
+
"react-native": ">=0.72.0"
|
|
87
73
|
},
|
|
88
74
|
"devDependencies": {
|
|
89
75
|
"@eslint/js": "^9.0.0",
|