react-native-marketap-sdk 0.1.0-beta.9 → 1.0.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/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +1 -10
- package/android/src/main/java/com/marketapsdk/MarketapSdkModule.kt +284 -77
- package/android/src/main/java/com/marketapsdk/ReactNativeBridgeRegistry.kt +110 -0
- package/ios/MarketapSdk.m +30 -23
- package/ios/MarketapSdk.swift +232 -162
- package/lib/commonjs/MarketapWebBridge.js +205 -15
- package/lib/commonjs/MarketapWebBridge.js.map +1 -1
- package/lib/commonjs/core/MarketapCore.js +233 -0
- package/lib/commonjs/core/MarketapCore.js.map +1 -0
- package/lib/commonjs/index.js +20 -165
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/marketapCore.js +9 -0
- package/lib/commonjs/internal/marketapCore.js.map +1 -0
- package/lib/commonjs/internal/marketapPlugin.js +40 -0
- package/lib/commonjs/internal/marketapPlugin.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/MarketapWebBridge.js +204 -15
- package/lib/module/MarketapWebBridge.js.map +1 -1
- package/lib/module/core/MarketapCore.js +226 -0
- package/lib/module/core/MarketapCore.js.map +1 -0
- package/lib/module/index.js +20 -164
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/marketapCore.js +3 -0
- package/lib/module/internal/marketapCore.js.map +1 -0
- package/lib/module/internal/marketapPlugin.js +35 -0
- package/lib/module/internal/marketapPlugin.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/MarketapWebBridge.d.ts +33 -6
- package/lib/typescript/MarketapWebBridge.d.ts.map +1 -1
- package/lib/typescript/core/MarketapCore.d.ts +54 -0
- package/lib/typescript/core/MarketapCore.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -41
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/internal/marketapCore.d.ts +3 -0
- package/lib/typescript/internal/marketapCore.d.ts.map +1 -0
- package/lib/typescript/internal/marketapPlugin.d.ts +10 -0
- package/lib/typescript/internal/marketapPlugin.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +1 -2
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-marketap-sdk.podspec +1 -1
package/ios/MarketapSdk.m
CHANGED
|
@@ -8,51 +8,41 @@
|
|
|
8
8
|
return YES;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
RCT_EXTERN_METHOD(initialize:(
|
|
11
|
+
RCT_EXTERN_METHOD(initialize:(nullable NSDictionary *)payload
|
|
12
12
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
13
13
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
14
14
|
|
|
15
|
-
RCT_EXTERN_METHOD(setLogLevel:(
|
|
15
|
+
RCT_EXTERN_METHOD(setLogLevel:(nullable NSDictionary *)payload)
|
|
16
16
|
|
|
17
|
-
RCT_EXTERN_METHOD(signup:(
|
|
18
|
-
userProperties:(nullable NSDictionary *)userProperties
|
|
19
|
-
eventProperties:(nullable NSDictionary *)eventProperties
|
|
20
|
-
persistUser:(nullable NSNumber *)persistUser
|
|
17
|
+
RCT_EXTERN_METHOD(signup:(nullable NSDictionary *)payload
|
|
21
18
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
22
19
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
23
20
|
|
|
24
|
-
RCT_EXTERN_METHOD(login:(
|
|
25
|
-
userProperties:(nullable NSDictionary *)userProperties
|
|
26
|
-
eventProperties:(nullable NSDictionary *)eventProperties
|
|
21
|
+
RCT_EXTERN_METHOD(login:(nullable NSDictionary *)payload
|
|
27
22
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
28
23
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
29
24
|
|
|
30
|
-
RCT_EXTERN_METHOD(logout:(nullable NSDictionary *)
|
|
25
|
+
RCT_EXTERN_METHOD(logout:(nullable NSDictionary *)payload
|
|
31
26
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
32
27
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
33
28
|
|
|
34
|
-
RCT_EXTERN_METHOD(track:(
|
|
35
|
-
eventProperties:(nullable NSDictionary *)eventProperties
|
|
29
|
+
RCT_EXTERN_METHOD(track:(nullable NSDictionary *)payload
|
|
36
30
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
37
31
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
38
32
|
|
|
39
|
-
RCT_EXTERN_METHOD(trackPurchase:(
|
|
40
|
-
eventProperties:(nullable NSDictionary *)eventProperties
|
|
33
|
+
RCT_EXTERN_METHOD(trackPurchase:(nullable NSDictionary *)payload
|
|
41
34
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
42
35
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
43
36
|
|
|
44
|
-
RCT_EXTERN_METHOD(trackRevenue:(
|
|
45
|
-
revenue:(nonnull NSNumber *)revenue
|
|
46
|
-
eventProperties:(nullable NSDictionary *)eventProperties
|
|
37
|
+
RCT_EXTERN_METHOD(trackRevenue:(nullable NSDictionary *)payload
|
|
47
38
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
48
39
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
49
40
|
|
|
50
|
-
RCT_EXTERN_METHOD(trackPageView:(nullable NSDictionary *)
|
|
41
|
+
RCT_EXTERN_METHOD(trackPageView:(nullable NSDictionary *)payload
|
|
51
42
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
52
43
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
53
44
|
|
|
54
|
-
RCT_EXTERN_METHOD(identify:(
|
|
55
|
-
userProperties:(nullable NSDictionary *)userProperties
|
|
45
|
+
RCT_EXTERN_METHOD(identify:(nullable NSDictionary *)payload
|
|
56
46
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
57
47
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
58
48
|
|
|
@@ -65,11 +55,28 @@ RCT_EXTERN_METHOD(setClickHandler:(RCTPromiseResolveBlock)resolve
|
|
|
65
55
|
RCT_EXTERN_METHOD(requestAuthorizationForPushNotifications:(RCTPromiseResolveBlock)resolve
|
|
66
56
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
67
57
|
|
|
68
|
-
RCT_EXTERN_METHOD(
|
|
58
|
+
RCT_EXTERN_METHOD(trackFromWebBridge:(nullable NSDictionary *)payload
|
|
69
59
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
70
60
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
71
61
|
|
|
72
|
-
RCT_EXTERN_METHOD(
|
|
62
|
+
RCT_EXTERN_METHOD(setUserProperties:(nullable NSDictionary *)payload
|
|
63
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
64
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
65
|
+
|
|
66
|
+
RCT_EXTERN_METHOD(trackInAppImpression:(nullable NSDictionary *)payload
|
|
67
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
68
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
69
|
+
|
|
70
|
+
RCT_EXTERN_METHOD(trackInAppClick:(nullable NSDictionary *)payload
|
|
71
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
72
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
73
|
+
|
|
74
|
+
RCT_EXTERN_METHOD(setDeviceOptIn:(nullable NSDictionary *)payload
|
|
75
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
76
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
77
|
+
|
|
78
|
+
RCT_EXTERN_METHOD(hideCampaign:(nullable NSDictionary *)payload
|
|
79
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
73
80
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
74
81
|
|
|
75
|
-
@end
|
|
82
|
+
@end
|
package/ios/MarketapSdk.swift
CHANGED
|
@@ -25,56 +25,65 @@ class MarketapSdk: RCTEventEmitter {
|
|
|
25
25
|
private var hasListeners = false
|
|
26
26
|
private var isInitialized = false
|
|
27
27
|
private var initializedProjectId: String?
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
private static var pendingClickEvent: [String: Any]? = nil
|
|
30
|
-
|
|
30
|
+
private static var pendingInAppMessageEvent: [String: Any]? = nil
|
|
31
|
+
private static var currentEmitter: MarketapSdk? = nil
|
|
32
|
+
private static var isExternalInAppCallbackRegistered = false
|
|
33
|
+
|
|
31
34
|
override init() {
|
|
32
35
|
super.init()
|
|
33
36
|
}
|
|
34
|
-
|
|
37
|
+
|
|
35
38
|
@objc
|
|
36
39
|
override static func requiresMainQueueSetup() -> Bool {
|
|
37
40
|
return true
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
|
|
40
43
|
override func supportedEvents() -> [String]! {
|
|
41
|
-
return ["MarketapClickEvent"]
|
|
44
|
+
return ["MarketapClickEvent", "MarketapInAppMessageEvent"]
|
|
42
45
|
}
|
|
43
|
-
|
|
46
|
+
|
|
44
47
|
override func startObserving() {
|
|
45
48
|
hasListeners = true
|
|
49
|
+
Self.currentEmitter = self
|
|
50
|
+
print("[MarketapSdk] startObserving (hasListeners=true)")
|
|
51
|
+
|
|
52
|
+
if let pendingEvent = Self.pendingInAppMessageEvent {
|
|
53
|
+
self.sendEvent(withName: "MarketapInAppMessageEvent", body: pendingEvent)
|
|
54
|
+
Self.pendingInAppMessageEvent = nil
|
|
55
|
+
}
|
|
46
56
|
}
|
|
47
|
-
|
|
57
|
+
|
|
48
58
|
override func stopObserving() {
|
|
49
59
|
hasListeners = false
|
|
60
|
+
if Self.currentEmitter === self {
|
|
61
|
+
Self.currentEmitter = nil
|
|
62
|
+
}
|
|
63
|
+
print("[MarketapSdk] stopObserving (hasListeners=false)")
|
|
50
64
|
}
|
|
51
|
-
|
|
65
|
+
|
|
52
66
|
@objc
|
|
53
|
-
func initialize(_
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
} else {
|
|
60
|
-
print("[MarketapSDK] Already initialized with projectId '\(initializedProjectId ?? "unknown")'. Ignoring re-initialization with '\(projectId)'.")
|
|
61
|
-
resolve(nil)
|
|
62
|
-
return
|
|
63
|
-
}
|
|
67
|
+
func initialize(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
68
|
+
let projectId = payload?["projectId"] as? String ?? ""
|
|
69
|
+
if isInitialized {
|
|
70
|
+
if initializedProjectId != projectId {
|
|
71
|
+
print("[MarketapSDK] Already initialized with projectId '\(initializedProjectId ?? "unknown")'. Ignoring re-initialization with '\(projectId)'.")
|
|
64
72
|
}
|
|
65
|
-
|
|
66
|
-
// Initialize MarketapSDK
|
|
67
|
-
Marketap.initialize(projectId: projectId)
|
|
68
|
-
isInitialized = true
|
|
69
|
-
initializedProjectId = projectId
|
|
70
73
|
resolve(nil)
|
|
71
|
-
|
|
72
|
-
reject("INITIALIZATION_ERROR", error.localizedDescription, error)
|
|
74
|
+
return
|
|
73
75
|
}
|
|
76
|
+
|
|
77
|
+
Marketap.initialize(projectId: projectId)
|
|
78
|
+
isInitialized = true
|
|
79
|
+
initializedProjectId = projectId
|
|
80
|
+
Self.registerExternalInAppCallbackIfNeeded()
|
|
81
|
+
resolve(nil)
|
|
74
82
|
}
|
|
75
83
|
|
|
76
84
|
@objc
|
|
77
|
-
func setLogLevel(_
|
|
85
|
+
func setLogLevel(_ payload: NSDictionary?) {
|
|
86
|
+
let logLevel = payload?["logLevel"] as? NSNumber ?? NSNumber(value: 0)
|
|
78
87
|
switch logLevel.intValue {
|
|
79
88
|
case 0:
|
|
80
89
|
Marketap.setLogLevel(.none)
|
|
@@ -92,178 +101,239 @@ class MarketapSdk: RCTEventEmitter {
|
|
|
92
101
|
Marketap.setLogLevel(.none)
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
|
-
|
|
104
|
+
|
|
96
105
|
@objc
|
|
97
|
-
func signup(_
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
106
|
+
func signup(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
107
|
+
let userId = payload?["userId"] as? String ?? ""
|
|
108
|
+
let userProperties = payload?["userProperties"] as? [String: Any]
|
|
109
|
+
let eventProperties = payload?["eventProperties"] as? [String: Any]
|
|
110
|
+
let persistUser = (payload?["persistUser"] as? NSNumber)?.boolValue ?? true
|
|
111
|
+
Marketap.signup(userId: userId, userProperties: userProperties, eventProperties: eventProperties, persistUser: persistUser)
|
|
112
|
+
resolve(nil)
|
|
105
113
|
}
|
|
106
|
-
|
|
114
|
+
|
|
107
115
|
@objc
|
|
108
|
-
func login(_
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
reject("LOGIN_ERROR", error.localizedDescription, error)
|
|
115
|
-
}
|
|
116
|
+
func login(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
117
|
+
let userId = payload?["userId"] as? String ?? ""
|
|
118
|
+
let userProperties = payload?["userProperties"] as? [String: Any]
|
|
119
|
+
let eventProperties = payload?["eventProperties"] as? [String: Any]
|
|
120
|
+
Marketap.login(userId: userId, userProperties: userProperties, eventProperties: eventProperties)
|
|
121
|
+
resolve(nil)
|
|
116
122
|
}
|
|
117
|
-
|
|
123
|
+
|
|
118
124
|
@objc
|
|
119
|
-
func logout(_
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
resolve(nil)
|
|
124
|
-
} catch {
|
|
125
|
-
reject("LOGOUT_ERROR", error.localizedDescription, error)
|
|
126
|
-
}
|
|
125
|
+
func logout(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
126
|
+
let eventProperties = payload?["eventProperties"] as? [String: Any]
|
|
127
|
+
Marketap.logout(eventProperties: eventProperties)
|
|
128
|
+
resolve(nil)
|
|
127
129
|
}
|
|
128
|
-
|
|
130
|
+
|
|
129
131
|
@objc
|
|
130
|
-
func track(_
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
} catch {
|
|
136
|
-
reject("TRACK_ERROR", error.localizedDescription, error)
|
|
137
|
-
}
|
|
132
|
+
func track(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
133
|
+
let eventName = payload?["eventName"] as? String ?? ""
|
|
134
|
+
let eventProperties = payload?["eventProperties"] as? [String: Any]
|
|
135
|
+
Marketap.track(eventName: eventName, eventProperties: eventProperties)
|
|
136
|
+
resolve(nil)
|
|
138
137
|
}
|
|
139
|
-
|
|
138
|
+
|
|
140
139
|
@objc
|
|
141
|
-
func trackPurchase(_
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} catch {
|
|
147
|
-
reject("TRACK_PURCHASE_ERROR", error.localizedDescription, error)
|
|
148
|
-
}
|
|
140
|
+
func trackPurchase(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
141
|
+
let revenue = (payload?["revenue"] as? NSNumber)?.doubleValue ?? 0
|
|
142
|
+
let eventProperties = payload?["eventProperties"] as? [String: Any]
|
|
143
|
+
Marketap.trackPurchase(revenue: revenue, eventProperties: eventProperties)
|
|
144
|
+
resolve(nil)
|
|
149
145
|
}
|
|
150
|
-
|
|
146
|
+
|
|
151
147
|
@objc
|
|
152
|
-
func trackRevenue(_
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
reject("TRACK_REVENUE_ERROR", error.localizedDescription, error)
|
|
159
|
-
}
|
|
148
|
+
func trackRevenue(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
149
|
+
let eventName = payload?["eventName"] as? String ?? ""
|
|
150
|
+
let revenue = (payload?["revenue"] as? NSNumber)?.doubleValue ?? 0
|
|
151
|
+
let eventProperties = payload?["eventProperties"] as? [String: Any]
|
|
152
|
+
Marketap.trackRevenue(eventName: eventName, revenue: revenue, eventProperties: eventProperties)
|
|
153
|
+
resolve(nil)
|
|
160
154
|
}
|
|
161
|
-
|
|
155
|
+
|
|
162
156
|
@objc
|
|
163
|
-
func trackPageView(_
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
resolve(nil)
|
|
168
|
-
} catch {
|
|
169
|
-
reject("TRACK_PAGE_VIEW_ERROR", error.localizedDescription, error)
|
|
170
|
-
}
|
|
157
|
+
func trackPageView(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
158
|
+
let eventProperties = payload?["eventProperties"] as? [String: Any]
|
|
159
|
+
Marketap.trackPageView(eventProperties: eventProperties)
|
|
160
|
+
resolve(nil)
|
|
171
161
|
}
|
|
172
|
-
|
|
162
|
+
|
|
173
163
|
@objc
|
|
174
|
-
func identify(_
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} catch {
|
|
180
|
-
reject("IDENTIFY_ERROR", error.localizedDescription, error)
|
|
181
|
-
}
|
|
164
|
+
func identify(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
165
|
+
let userId = payload?["userId"] as? String ?? ""
|
|
166
|
+
let userProperties = payload?["userProperties"] as? [String: Any]
|
|
167
|
+
Marketap.identify(userId: userId, userProperties: userProperties)
|
|
168
|
+
resolve(nil)
|
|
182
169
|
}
|
|
183
|
-
|
|
170
|
+
|
|
184
171
|
@objc
|
|
185
172
|
func resetIdentity(_ resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
Marketap.resetIdentity()
|
|
189
|
-
resolve(nil)
|
|
190
|
-
} catch {
|
|
191
|
-
reject("RESET_IDENTITY_ERROR", error.localizedDescription, error)
|
|
192
|
-
}
|
|
173
|
+
Marketap.resetIdentity()
|
|
174
|
+
resolve(nil)
|
|
193
175
|
}
|
|
194
|
-
|
|
176
|
+
|
|
195
177
|
@objc
|
|
196
178
|
func setClickHandler(_ resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}()
|
|
206
|
-
|
|
207
|
-
let clickData: [String: Any] = [
|
|
208
|
-
"campaignType": campaignType,
|
|
209
|
-
"campaignId": event.campaignId,
|
|
210
|
-
"url": event.url ?? NSNull()
|
|
211
|
-
]
|
|
212
|
-
|
|
213
|
-
if let self = self, self.hasListeners {
|
|
214
|
-
self.sendEvent(withName: "MarketapClickEvent", body: clickData)
|
|
215
|
-
Self.pendingClickEvent = nil
|
|
216
|
-
} else {
|
|
217
|
-
Self.pendingClickEvent = clickData
|
|
179
|
+
print("[MarketapSdk] setClickHandler called")
|
|
180
|
+
Marketap.setClickHandler { [weak self] event in
|
|
181
|
+
print("[MarketapSdk] click event received")
|
|
182
|
+
let campaignType: String = {
|
|
183
|
+
switch event.campaignType {
|
|
184
|
+
case .push: return "push"
|
|
185
|
+
case .inAppMessage: return "inAppMessage"
|
|
186
|
+
@unknown default: return "unknown"
|
|
218
187
|
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
188
|
+
}()
|
|
189
|
+
|
|
190
|
+
let clickData: [String: Any] = [
|
|
191
|
+
"campaignType": campaignType,
|
|
192
|
+
"campaignId": event.campaignId,
|
|
193
|
+
"url": event.url ?? NSNull()
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
if let self = self, self.hasListeners {
|
|
197
|
+
self.sendEvent(withName: "MarketapClickEvent", body: clickData)
|
|
223
198
|
Self.pendingClickEvent = nil
|
|
199
|
+
} else {
|
|
200
|
+
Self.pendingClickEvent = clickData
|
|
224
201
|
}
|
|
225
|
-
|
|
226
|
-
resolve(nil)
|
|
227
|
-
} catch {
|
|
228
|
-
reject("SET_CLICK_HANDLER_ERROR", error.localizedDescription, error)
|
|
229
202
|
}
|
|
203
|
+
|
|
204
|
+
if let pendingEvent = Self.pendingClickEvent {
|
|
205
|
+
self.sendEvent(withName: "MarketapClickEvent", body: pendingEvent)
|
|
206
|
+
Self.pendingClickEvent = nil
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
resolve(nil)
|
|
230
210
|
}
|
|
231
|
-
|
|
211
|
+
|
|
232
212
|
@objc
|
|
233
213
|
func requestAuthorizationForPushNotifications(_ resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
214
|
+
Marketap.requestAuthorizationForPushNotifications()
|
|
215
|
+
resolve(nil)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// MARK: - WebBridge In-App Methods
|
|
219
|
+
|
|
220
|
+
@objc
|
|
221
|
+
func trackFromWebBridge(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
222
|
+
let eventName = payload?["eventName"] as? String ?? ""
|
|
223
|
+
let eventProperties = payload?["eventProperties"] as? [String: Any]
|
|
224
|
+
let handleInApp = (payload?["handleInAppInReactNative"] as? NSNumber)?.boolValue ?? false
|
|
225
|
+
|
|
226
|
+
if handleInApp {
|
|
227
|
+
MarketapWebBridge.setExternalWebBridgeActive(true)
|
|
228
|
+
} else {
|
|
229
|
+
MarketapWebBridge.setExternalWebBridgeActive(false)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
MarketapPlugin.trackEvent(eventName: eventName, eventProperties: eventProperties)
|
|
233
|
+
resolve(nil)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@objc
|
|
237
|
+
func setUserProperties(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
238
|
+
let userProperties = payload?["userProperties"] as? [String: Any]
|
|
239
|
+
guard let userProperties = userProperties else {
|
|
240
|
+
reject("ARG_ERROR", "Missing userProperties", nil)
|
|
241
|
+
return
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
MarketapPlugin.setUserProperties(userProperties: userProperties)
|
|
245
|
+
resolve(nil)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@objc
|
|
249
|
+
func trackInAppImpression(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
250
|
+
let campaignId = payload?["campaignId"] as? String
|
|
251
|
+
let messageId = payload?["messageId"] as? String
|
|
252
|
+
let layoutSubType = payload?["layoutSubType"] as? String
|
|
253
|
+
guard let campaignId = campaignId, let messageId = messageId else {
|
|
254
|
+
print("[MarketapSdk] trackInAppImpression: missing required params (campaignId=\(String(describing: campaignId)), messageId=\(String(describing: messageId)))")
|
|
237
255
|
resolve(nil)
|
|
238
|
-
|
|
239
|
-
reject("PUSH_PERMISSION_ERROR", error.localizedDescription, error)
|
|
256
|
+
return
|
|
240
257
|
}
|
|
258
|
+
|
|
259
|
+
MarketapPlugin.trackInAppImpression(
|
|
260
|
+
campaignId: campaignId,
|
|
261
|
+
messageId: messageId,
|
|
262
|
+
layoutSubType: layoutSubType
|
|
263
|
+
)
|
|
264
|
+
resolve(nil)
|
|
241
265
|
}
|
|
242
|
-
|
|
266
|
+
|
|
243
267
|
@objc
|
|
244
|
-
func
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
268
|
+
func trackInAppClick(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
269
|
+
let campaignId = payload?["campaignId"] as? String
|
|
270
|
+
let messageId = payload?["messageId"] as? String
|
|
271
|
+
let locationId = payload?["locationId"] as? String
|
|
272
|
+
let url = payload?["url"] as? String
|
|
273
|
+
let layoutSubType = payload?["layoutSubType"] as? String
|
|
274
|
+
guard let campaignId = campaignId, let messageId = messageId, let locationId = locationId else {
|
|
275
|
+
print("[MarketapSdk] trackInAppClick: missing required params (campaignId=\(String(describing: campaignId)), messageId=\(String(describing: messageId)), locationId=\(String(describing: locationId)))")
|
|
250
276
|
resolve(nil)
|
|
251
|
-
|
|
252
|
-
reject("PUSH_TOKEN_ERROR", error.localizedDescription, error)
|
|
277
|
+
return
|
|
253
278
|
}
|
|
279
|
+
|
|
280
|
+
MarketapPlugin.trackInAppClick(
|
|
281
|
+
campaignId: campaignId,
|
|
282
|
+
messageId: messageId,
|
|
283
|
+
locationId: locationId,
|
|
284
|
+
url: url,
|
|
285
|
+
layoutSubType: layoutSubType
|
|
286
|
+
)
|
|
287
|
+
resolve(nil)
|
|
254
288
|
}
|
|
255
|
-
|
|
289
|
+
|
|
256
290
|
@objc
|
|
257
|
-
func
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
291
|
+
func setDeviceOptIn(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
292
|
+
let optIn: Bool?
|
|
293
|
+
if let value = payload?["optIn"] as? NSNumber {
|
|
294
|
+
optIn = value.boolValue
|
|
295
|
+
} else {
|
|
296
|
+
optIn = nil
|
|
297
|
+
}
|
|
298
|
+
Marketap.setDeviceOptIn(optIn: optIn)
|
|
299
|
+
resolve(nil)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
@objc
|
|
303
|
+
func hideCampaign(_ payload: NSDictionary?, withResolver resolve: @escaping RCTPromiseResolveBlock, withRejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
304
|
+
let campaignId = payload?["campaignId"] as? String
|
|
305
|
+
let hideType = payload?["hideType"] as? String
|
|
306
|
+
guard let campaignId = campaignId else {
|
|
307
|
+
print("[MarketapSdk] hideCampaign: missing campaignId")
|
|
308
|
+
resolve(nil)
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
MarketapPlugin.hideInAppMessage(campaignId: campaignId, hideType: hideType)
|
|
313
|
+
resolve(nil)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// MARK: - Private
|
|
317
|
+
|
|
318
|
+
private static func registerExternalInAppCallbackIfNeeded() {
|
|
319
|
+
if isExternalInAppCallbackRegistered {
|
|
320
|
+
return
|
|
321
|
+
}
|
|
322
|
+
isExternalInAppCallbackRegistered = true
|
|
323
|
+
|
|
324
|
+
MarketapWebBridge.setExternalInAppMessageCallback { campaign, messageId, hasCustomClickHandler in
|
|
325
|
+
let payload: [String: Any] = [
|
|
326
|
+
"campaign": campaign,
|
|
327
|
+
"messageId": messageId,
|
|
328
|
+
"hasCustomClickHandler": hasCustomClickHandler
|
|
329
|
+
]
|
|
330
|
+
|
|
331
|
+
if let emitter = currentEmitter, emitter.hasListeners {
|
|
332
|
+
emitter.sendEvent(withName: "MarketapInAppMessageEvent", body: payload)
|
|
333
|
+
pendingInAppMessageEvent = nil
|
|
262
334
|
} else {
|
|
263
|
-
|
|
335
|
+
pendingInAppMessageEvent = payload
|
|
264
336
|
}
|
|
265
|
-
} catch {
|
|
266
|
-
reject("GET_INITIAL_NOTIFICATION_ERROR", error.localizedDescription, error)
|
|
267
337
|
}
|
|
268
338
|
}
|
|
269
|
-
}
|
|
339
|
+
}
|