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
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
package com.marketapsdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
|
4
|
+
|
|
5
|
+
internal interface ReactNativeBridgeTarget {
|
|
6
|
+
val isAttachedToReact: Boolean
|
|
7
|
+
val isClickHandlerRegistered: Boolean
|
|
8
|
+
val isReactReady: Boolean
|
|
9
|
+
|
|
10
|
+
fun sendInAppMessage(
|
|
11
|
+
campaign: Map<String, Any?>,
|
|
12
|
+
messageId: String,
|
|
13
|
+
shouldHandleUrlRouting: Boolean
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
fun sendClick(clickData: WritableMap)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
internal object ReactNativeBridgeRegistry {
|
|
20
|
+
private val activeTargets: MutableList<ReactNativeBridgeTarget> = mutableListOf()
|
|
21
|
+
|
|
22
|
+
private val clickHandlerTargets: List<ReactNativeBridgeTarget>
|
|
23
|
+
get() = activeTargets.filter { it.isClickHandlerRegistered && it.isAttachedToReact }
|
|
24
|
+
private val attachedTargets: List<ReactNativeBridgeTarget>
|
|
25
|
+
get() = activeTargets.filter { it.isAttachedToReact }
|
|
26
|
+
|
|
27
|
+
private var lastPendingClick: WritableMap? = null
|
|
28
|
+
|
|
29
|
+
// trackFromWebBridge를 호출한 타겟 (인앱 메시지 전달 대상)
|
|
30
|
+
private var webBridgeSourceTarget: ReactNativeBridgeTarget? = null
|
|
31
|
+
|
|
32
|
+
fun register(target: ReactNativeBridgeTarget) {
|
|
33
|
+
log("Register target: $target")
|
|
34
|
+
activeTargets.add(target)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun unregister(target: ReactNativeBridgeTarget) {
|
|
38
|
+
log("Unregister target: $target")
|
|
39
|
+
activeTargets.remove(target)
|
|
40
|
+
if (webBridgeSourceTarget == target) {
|
|
41
|
+
webBridgeSourceTarget = null
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* trackFromWebBridge 호출 시 소스 타겟 설정
|
|
47
|
+
*/
|
|
48
|
+
fun setWebBridgeSourceTarget(target: ReactNativeBridgeTarget) {
|
|
49
|
+
webBridgeSourceTarget = target
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 소스 타겟 초기화
|
|
54
|
+
*/
|
|
55
|
+
fun clearWebBridgeSourceTarget() {
|
|
56
|
+
webBridgeSourceTarget = null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 네이티브 SDK에서 RN으로 인앱 메시지 전달
|
|
61
|
+
* trackFromWebBridge를 호출한 타겟에만 전달
|
|
62
|
+
*/
|
|
63
|
+
fun sendInAppMessage(
|
|
64
|
+
campaign: Map<String, Any?>,
|
|
65
|
+
messageId: String,
|
|
66
|
+
shouldHandleUrlRouting: Boolean
|
|
67
|
+
) {
|
|
68
|
+
val target = webBridgeSourceTarget
|
|
69
|
+
webBridgeSourceTarget = null
|
|
70
|
+
|
|
71
|
+
if (target != null && target.isAttachedToReact && target.isReactReady) {
|
|
72
|
+
target.sendInAppMessage(campaign, messageId, shouldHandleUrlRouting)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fun flushIfPending() {
|
|
77
|
+
log("flush called, $lastPendingClick")
|
|
78
|
+
lastPendingClick?.let { clickData ->
|
|
79
|
+
log("Flush pending click on new instance: $clickData")
|
|
80
|
+
deliverClick(clickData)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fun deliverClick(clickData: WritableMap) {
|
|
85
|
+
log("Deliver click: $clickData")
|
|
86
|
+
val readyTargets = clickHandlerTargets.filter { it.isReactReady }
|
|
87
|
+
if (readyTargets.isNotEmpty()) {
|
|
88
|
+
log("There are ${readyTargets.size} click handler targets available; delivery click: $clickData")
|
|
89
|
+
readyTargets.forEach { target ->
|
|
90
|
+
log("Deliver click to $target: $clickData")
|
|
91
|
+
target.sendClick(clickData)
|
|
92
|
+
}
|
|
93
|
+
lastPendingClick = null
|
|
94
|
+
} else {
|
|
95
|
+
log("Targets not ready; store click: $clickData")
|
|
96
|
+
lastPendingClick = clickData
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fun popPendingClick(): WritableMap? {
|
|
101
|
+
val pending = lastPendingClick
|
|
102
|
+
lastPendingClick = null
|
|
103
|
+
return pending
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private fun log(message: String) {
|
|
107
|
+
// TODO: route to Marketap logger when available in RN layer
|
|
108
|
+
android.util.Log.d("MarketapBridgeRegistry", message)
|
|
109
|
+
}
|
|
110
|
+
}
|
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,35 @@ 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(onWebBridgeConnected:(nullable NSDictionary *)payload
|
|
63
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
64
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
65
|
+
|
|
66
|
+
RCT_EXTERN_METHOD(onWebSdkInitialized:(RCTPromiseResolveBlock)resolve
|
|
67
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
68
|
+
|
|
69
|
+
RCT_EXTERN_METHOD(setUserProperties:(nullable NSDictionary *)payload
|
|
70
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
71
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
72
|
+
|
|
73
|
+
RCT_EXTERN_METHOD(trackInAppImpression:(nullable NSDictionary *)payload
|
|
74
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
75
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
76
|
+
|
|
77
|
+
RCT_EXTERN_METHOD(trackInAppClick:(nullable NSDictionary *)payload
|
|
78
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
79
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
80
|
+
|
|
81
|
+
RCT_EXTERN_METHOD(setDeviceOptIn:(nullable NSDictionary *)payload
|
|
82
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
83
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
84
|
+
|
|
85
|
+
RCT_EXTERN_METHOD(hideCampaign:(nullable NSDictionary *)payload
|
|
86
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
73
87
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
74
88
|
|
|
75
|
-
@end
|
|
89
|
+
@end
|