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