tagworks-sdk-v1-react 1.1.20 → 1.1.22

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.
Files changed (62) hide show
  1. package/LICENSE +3 -1
  2. package/README.md +35 -552
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/com/tagworkssdkv1/DataBundleModule.kt +340 -366
  5. package/android/src/main/java/com/tagworkssdkv1/OnCmsBannerViewManager.kt +15 -4
  6. package/android/src/main/java/com/tagworkssdkv1/TagWorksDeeplinkModule.kt +117 -0
  7. package/android/src/main/java/com/tagworkssdkv1/TagWorksModule.kt +417 -376
  8. package/android/src/main/java/com/tagworkssdkv1/TagWorksPopupModule.kt +22 -26
  9. package/android/src/main/java/com/tagworkssdkv1/TagworksSdkV1Package.kt +3 -2
  10. package/ios/DataBundleModule.swift +8 -8
  11. package/ios/OnCmsBannerViewManager.swift +6 -5
  12. package/ios/TagWorksDeeplinkModule.swift +64 -0
  13. package/ios/TagWorksDeeplinkModuleBridge.m +19 -0
  14. package/ios/TagWorksModule.swift +113 -27
  15. package/ios/TagWorksModuleBridge.m +20 -2
  16. package/ios/TagWorksPopupModule.swift +41 -18
  17. package/ios/TagWorksPopupModuleBridge.m +2 -0
  18. package/lib/commonjs/RegisterOnCmsBannerView.js +10 -0
  19. package/lib/commonjs/RegisterOnCmsBannerView.js.map +1 -0
  20. package/lib/commonjs/TagWorksDeeplink.js +48 -0
  21. package/lib/commonjs/TagWorksDeeplink.js.map +1 -0
  22. package/lib/commonjs/autoTrackers/ReactNavigationPageTracker.js +135 -0
  23. package/lib/commonjs/autoTrackers/ReactNavigationPageTracker.js.map +1 -0
  24. package/lib/commonjs/index.js +36 -10
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/module/RegisterOnCmsBannerView.js +6 -0
  27. package/lib/module/RegisterOnCmsBannerView.js.map +1 -0
  28. package/lib/module/TagWorksDeeplink.js +44 -0
  29. package/lib/module/TagWorksDeeplink.js.map +1 -0
  30. package/lib/module/autoTrackers/ReactNavigationPageTracker.js +131 -0
  31. package/lib/module/autoTrackers/ReactNavigationPageTracker.js.map +1 -0
  32. package/lib/module/index.js +15 -11
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/typescript/commonjs/babel.config.d.ts +2 -0
  35. package/lib/typescript/commonjs/babel.config.d.ts.map +1 -0
  36. package/lib/typescript/commonjs/src/RegisterOnCmsBannerView.d.ts +3 -0
  37. package/lib/typescript/commonjs/src/RegisterOnCmsBannerView.d.ts.map +1 -0
  38. package/lib/typescript/commonjs/src/TagWorksDeeplink.d.ts +23 -0
  39. package/lib/typescript/commonjs/src/TagWorksDeeplink.d.ts.map +1 -0
  40. package/lib/typescript/commonjs/src/autoTrackers/ReactNavigationPageTracker.d.ts +12 -0
  41. package/lib/typescript/commonjs/src/autoTrackers/ReactNavigationPageTracker.d.ts.map +1 -0
  42. package/lib/typescript/commonjs/src/index.d.ts +9 -3
  43. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  44. package/lib/typescript/module/babel.config.d.ts +2 -0
  45. package/lib/typescript/module/babel.config.d.ts.map +1 -0
  46. package/lib/typescript/module/src/RegisterOnCmsBannerView.d.ts +3 -0
  47. package/lib/typescript/module/src/RegisterOnCmsBannerView.d.ts.map +1 -0
  48. package/lib/typescript/module/src/TagWorksDeeplink.d.ts +23 -0
  49. package/lib/typescript/module/src/TagWorksDeeplink.d.ts.map +1 -0
  50. package/lib/typescript/module/src/autoTrackers/ReactNavigationPageTracker.d.ts +12 -0
  51. package/lib/typescript/module/src/autoTrackers/ReactNavigationPageTracker.d.ts.map +1 -0
  52. package/lib/typescript/module/src/index.d.ts +9 -3
  53. package/lib/typescript/module/src/index.d.ts.map +1 -1
  54. package/package.json +28 -8
  55. package/src/RegisterOnCmsBannerView.js +5 -0
  56. package/src/TagWorksDeeplink.js +45 -0
  57. package/src/autoTrackers/ReactNavigationPageTracker.js +137 -0
  58. package/src/index.js +48 -0
  59. package/tagworks-sdk-v1-react.podspec +9 -2
  60. package/android/src/main/java/com/tagworkssdkv1/TagworksSdkV1Module.kt +0 -25
  61. package/android/src/main/res/drawable/default_img.png +0 -0
  62. package/src/index.tsx +0 -27
@@ -1,6 +1,5 @@
1
1
  package com.tagworkssdkv1
2
2
 
3
- import android.util.Log
4
3
  import android.widget.FrameLayout
5
4
  import com.facebook.react.bridge.ReactContext
6
5
  import com.facebook.react.uimanager.SimpleViewManager
@@ -8,12 +7,22 @@ import com.facebook.react.uimanager.ThemedReactContext
8
7
  import com.facebook.react.uimanager.annotations.ReactProp
9
8
  import com.obzen.tagworks.TagWorksPopup
10
9
 
10
+ /**
11
+ * React Native에서 사용할 수 있는 커스텀 네이티브 View를 정의하는 ViewManager 클래스
12
+ * FrameLayout을 기반으로 하며, 외부에서 전달된 props를 통해 배너를 갱신.
13
+ * Created by obzen on 2025-04-23
14
+ */
11
15
  class OnCmsBannerViewManager: SimpleViewManager<FrameLayout>() {
16
+
12
17
  private var onCmsUrl: String = ""
13
18
  private var custId: String? = ""
14
19
  private var rcmdAreaCd: String = ""
15
20
  private var defaultImage: String = ""
16
21
 
22
+ /**
23
+ * 실제 Native View를 생성하는 함수.
24
+ * React Native에서 <OnCmsBannerView />를 선언하면 호출.
25
+ */
17
26
  override fun createViewInstance(reactContext: ThemedReactContext): FrameLayout {
18
27
  val frameLayout= FrameLayout(reactContext)
19
28
 
@@ -44,10 +53,12 @@ class OnCmsBannerViewManager: SimpleViewManager<FrameLayout>() {
44
53
  attachBanner(view)
45
54
  }
46
55
 
56
+ /**
57
+ * 설정된 배너 데이터를 바탕으로 실제 배너를 View에 붙이는 함수.
58
+ * 모든 필수 데이터가 들어왔을 때만 실행되며, 내부적으로 TagWorksPopup 모듈을 호출.
59
+ */
47
60
  private fun attachBanner(container: FrameLayout) {
48
- // 두 값이 모두 설정되지 않았으면 안 함
49
- if (onCmsUrl.isEmpty() || rcmdAreaCd.isEmpty()) return
50
- Log.d("TAG", "attachBanner: attachbanner")
61
+
51
62
  val context = container.context
52
63
  val activity = (context as? ReactContext)?.currentActivity
53
64
 
@@ -0,0 +1,117 @@
1
+ package com.tagworkssdkv1
2
+
3
+ import android.app.Activity
4
+ import android.content.Intent
5
+ import android.net.Uri
6
+ import com.facebook.react.bridge.ActivityEventListener
7
+ import com.facebook.react.bridge.Arguments
8
+ import com.facebook.react.bridge.Promise
9
+ import com.facebook.react.bridge.ReactApplicationContext
10
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
11
+ import com.facebook.react.bridge.ReactMethod
12
+ import com.facebook.react.bridge.UiThreadUtil
13
+ import com.facebook.react.modules.core.RCTNativeAppEventEmitter
14
+ import com.obzen.tagworks.TagWorks
15
+ import com.obzen.tagworks.TagWorksDeeplink
16
+ import com.obzen.tagworks.common.Logger
17
+
18
+ class TagWorksDeeplinkModule(private val reactContext: ReactApplicationContext) :
19
+ ReactContextBaseJavaModule(reactContext),ActivityEventListener {
20
+
21
+ init {
22
+ reactContext.addActivityEventListener(this)
23
+ }
24
+
25
+ companion object {
26
+ const val NAME = "TagWorksDeeplinkModule"
27
+ private const val EVENT_NAME = "TagWorks_DeeplinkEvent"
28
+ }
29
+
30
+ override fun getName(): String {
31
+ return NAME
32
+ }
33
+
34
+ @ReactMethod
35
+ fun addListener(eventName: String) {
36
+ // RN이 이벤트 리스너 수 관리할 때 호출됨. 아무 것도 안 해도 됨.
37
+ }
38
+
39
+ @ReactMethod
40
+ fun removeListeners(count: Int) {
41
+ // RN이 리스너 해제할 때 호출됨. 아무 것도 안 해도 됨.
42
+ }
43
+
44
+ @ReactMethod
45
+ fun handleDeeplinkUrl(url: String) {
46
+ try {
47
+ val uri = Uri.parse(url)
48
+ val handled = TagWorksDeeplink.handleDeeplink(uri) { landing ->
49
+ UiThreadUtil.runOnUiThread {
50
+ emitDeeplink(landing, landing != null)
51
+ }
52
+ }
53
+ if (!handled) {
54
+ UiThreadUtil.runOnUiThread { emitDeeplink(null, false) }
55
+ }
56
+ } catch (t: Throwable) {
57
+ Logger.e(TagWorks.getInstance().tag, "reportDeeplinkUrl error for: $url")
58
+ UiThreadUtil.runOnUiThread { emitDeeplink(null, false) }
59
+ }
60
+ }
61
+
62
+
63
+ @ReactMethod
64
+ fun handleDeferredDeeplink(promise: Promise) {
65
+ try {
66
+ val firstCall = handleDeferredInternal { landing ->
67
+ promise.resolve(landing?.toString())
68
+ landing?.let { emitDeeplink(it, true) }
69
+ }
70
+ if (!firstCall) {
71
+ emitDeeplink(null, false)
72
+ promise.resolve(null)
73
+ }
74
+ } catch (e: Exception) {
75
+ promise.reject("DEFERRED_ERROR", e)
76
+ }
77
+ }
78
+
79
+ private fun handleDeferredInternal(onLandingUri: (Uri?) -> Unit): Boolean {
80
+ return try {
81
+ val first = TagWorksDeeplink.handleDeferredDeeplink(onLandingUri)
82
+ first
83
+ } catch (e: Exception) {
84
+ onLandingUri(null)
85
+ false
86
+ }
87
+
88
+ }
89
+
90
+ // ==== 이벤트 emit: JS에서 TagWorks.deeplinkListener / deferredDeeplinkListener로 받음 ====
91
+ private fun emitDeeplink(uri: Uri?, handled: Boolean) {
92
+ val params = Arguments.createMap().apply {
93
+ putString("deeplinkURL", uri?.toString())
94
+ putBoolean("isTagWorksDeeplink", handled)
95
+ }
96
+ UiThreadUtil.runOnUiThread {
97
+ reactContext
98
+ .getJSModule(RCTNativeAppEventEmitter::class.java)
99
+ .emit(EVENT_NAME, params)
100
+ }
101
+ }
102
+
103
+ override fun onActivityResult(
104
+ activity: Activity,
105
+ requestCode: Int,
106
+ resultCode: Int,
107
+ data: Intent?
108
+ ) {
109
+ // 필요 시 처리 (requestCode/결과 파싱 등)
110
+ }
111
+
112
+ override fun onNewIntent(intent: Intent) {
113
+ // 필요 시 현재 액티비티의 인텐트 갱신
114
+ reactContext.currentActivity?.intent = intent
115
+ }
116
+
117
+ }