@adstage/react-native-sdk 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -87,6 +87,31 @@ buildscript {
87
87
  }
88
88
  ```
89
89
 
90
+ #### 3. 딥링크 설정 (URL Scheme)
91
+
92
+ `AndroidManifest.xml`에 Intent Filter 추가:
93
+
94
+ ```xml
95
+ <activity
96
+ android:name=".MainActivity"
97
+ android:launchMode="singleTask">
98
+
99
+ <!-- URL Scheme 딥링크 -->
100
+ <intent-filter>
101
+ <action android:name="android.intent.action.VIEW" />
102
+ <category android:name="android.intent.category.DEFAULT" />
103
+ <category android:name="android.intent.category.BROWSABLE" />
104
+ <data android:scheme="your_app_scheme" />
105
+ </intent-filter>
106
+ </activity>
107
+ ```
108
+
109
+ > **📌 참고**: SDK v1.0.4부터 `MainActivity`에서 `onNewIntent` 오버라이드가 필요 없습니다.
110
+ > SDK가 `ActivityEventListener`를 통해 Warm Start 딥링크를 자동으로 처리합니다.
111
+ }
112
+ }
113
+ ```
114
+
90
115
  ## 빠른 시작
91
116
 
92
117
  ### 1. SDK 초기화
@@ -1,5 +1,7 @@
1
1
  package io.nbase.adstage.reactnative
2
2
 
3
+ import android.app.Activity
4
+ import android.content.Intent
3
5
  import android.util.Log
4
6
  import com.facebook.react.bridge.*
5
7
  import com.facebook.react.modules.core.DeviceEventManagerModule
@@ -20,7 +22,8 @@ import kotlinx.coroutines.launch
20
22
  * @since 3.0.0
21
23
  */
22
24
  class AdStageModule(reactContext: ReactApplicationContext) :
23
- ReactContextBaseJavaModule(reactContext) {
25
+ ReactContextBaseJavaModule(reactContext),
26
+ ActivityEventListener {
24
27
 
25
28
  companion object {
26
29
  private const val TAG = "AdStageModule"
@@ -29,8 +32,31 @@ class AdStageModule(reactContext: ReactApplicationContext) :
29
32
 
30
33
  private val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())
31
34
 
35
+ init {
36
+ reactContext.addActivityEventListener(this)
37
+ }
38
+
32
39
  override fun getName(): String = MODULE_NAME
33
40
 
41
+ // ============================================
42
+ // ActivityEventListener
43
+ // ============================================
44
+
45
+ /**
46
+ * 앱이 이미 실행 중일 때 새로운 딥링크 Intent 수신 (Warm Start)
47
+ * MainActivity에서 onNewIntent 오버라이드 불필요
48
+ */
49
+ override fun onNewIntent(intent: Intent?) {
50
+ Log.d(TAG, "onNewIntent received: ${intent?.data}")
51
+ reactApplicationContext.currentActivity?.let { activity ->
52
+ AdStage.handleIntent(activity, intent)
53
+ }
54
+ }
55
+
56
+ override fun onActivityResult(activity: Activity?, requestCode: Int, resultCode: Int, data: Intent?) {
57
+ // 현재 사용하지 않음
58
+ }
59
+
34
60
  // ============================================
35
61
  // Initialization
36
62
  // ============================================
@@ -40,7 +66,7 @@ class AdStageModule(reactContext: ReactApplicationContext) :
40
66
  try {
41
67
  Log.d(TAG, "Initializing AdStage SDK...")
42
68
 
43
- val context = currentActivity ?: reactApplicationContext
69
+ val context = reactApplicationContext.currentActivity ?: reactApplicationContext
44
70
 
45
71
  // serverUrl이 빈 문자열이면 기본값 사용 (iOS와 동일한 처리)
46
72
  if (serverUrl.isEmpty()) {
@@ -233,7 +259,7 @@ class AdStageModule(reactContext: ReactApplicationContext) :
233
259
 
234
260
  @ReactMethod
235
261
  fun handleIntent() {
236
- currentActivity?.let { activity ->
262
+ reactApplicationContext.currentActivity?.let { activity ->
237
263
  AdStage.handleIntent(activity, activity.intent)
238
264
  }
239
265
  }
@@ -285,7 +311,7 @@ class AdStageModule(reactContext: ReactApplicationContext) :
285
311
  fun handlePromotionClick(promotionMap: ReadableMap, promise: Promise) {
286
312
  scope.launch {
287
313
  try {
288
- val context = currentActivity ?: reactApplicationContext
314
+ val context = reactApplicationContext.currentActivity ?: reactApplicationContext
289
315
 
290
316
  // ReadableMap에서 Promotion 객체 복원
291
317
  val promotion = mapToPromotion(promotionMap)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adstage/react-native-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "AdStage SDK for React Native - 광고 어트리뷰션, 딥링크, 인앱 이벤트 트래킹",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",