react-native-firework-sdk 1.2.0-beta.9 → 1.2.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.
Files changed (87) hide show
  1. package/android/src/main/AndroidManifest.xml +0 -8
  2. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt +2 -1
  3. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +2 -2
  4. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt +2 -1
  5. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +7 -22
  6. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +4 -19
  7. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +28 -9
  8. package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWContainerActivity.kt +22 -10
  9. package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWDataUtils.kt +119 -0
  10. package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +38 -3
  11. package/android/src/main/java/com/fireworksdk/bridge/utils/FWBundleUtils.kt +86 -0
  12. package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +0 -1
  13. package/ios/FireworkSdk.xcodeproj/project.pbxproj +0 -4
  14. package/ios/Modules/FWNavigatorModule/FWNavigatorContainerViewController.swift +3 -11
  15. package/ios/Modules/FWNavigatorModule/FWNavigatorModule.m +2 -2
  16. package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +20 -10
  17. package/ios/Modules/FWNavigatorModule/FWNavigatorProtocol.swift +2 -2
  18. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +14 -6
  19. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +2 -1
  20. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +12 -4
  21. package/ios/Modules/Shopping/CartViewController.swift +6 -1
  22. package/ios/Modules/Shopping/ShoppingModule.m +1 -2
  23. package/ios/Modules/Shopping/ShoppingModule.swift +10 -12
  24. package/lib/commonjs/FWNavigator.js +7 -13
  25. package/lib/commonjs/FWNavigator.js.map +1 -1
  26. package/lib/commonjs/FireworkSDK.js +24 -12
  27. package/lib/commonjs/FireworkSDK.js.map +1 -1
  28. package/lib/commonjs/VideoShopping.js +3 -16
  29. package/lib/commonjs/VideoShopping.js.map +1 -1
  30. package/lib/commonjs/index.js +0 -14
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/models/NewNativeContainerProps.js +2 -0
  33. package/lib/commonjs/models/NewNativeContainerProps.js.map +1 -0
  34. package/lib/commonjs/modules/FWNavigatorModule.js.map +1 -1
  35. package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
  36. package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
  37. package/lib/module/FWNavigator.js +8 -14
  38. package/lib/module/FWNavigator.js.map +1 -1
  39. package/lib/module/FireworkSDK.js +23 -11
  40. package/lib/module/FireworkSDK.js.map +1 -1
  41. package/lib/module/VideoShopping.js +3 -16
  42. package/lib/module/VideoShopping.js.map +1 -1
  43. package/lib/module/index.js +0 -7
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/models/NewNativeContainerProps.js +2 -0
  46. package/lib/module/models/NewNativeContainerProps.js.map +1 -0
  47. package/lib/module/modules/FWNavigatorModule.js.map +1 -1
  48. package/lib/module/modules/FireworkSDKModule.js.map +1 -1
  49. package/lib/module/modules/ShoppingModule.js.map +1 -1
  50. package/lib/typescript/FWNavigator.d.ts +8 -7
  51. package/lib/typescript/FireworkSDK.d.ts +11 -6
  52. package/lib/typescript/VideoShopping.d.ts +2 -9
  53. package/lib/typescript/index.d.ts +2 -1
  54. package/lib/typescript/models/NewNativeContainerProps.d.ts +6 -0
  55. package/lib/typescript/modules/FWNavigatorModule.d.ts +3 -1
  56. package/lib/typescript/modules/FireworkSDKModule.d.ts +2 -1
  57. package/lib/typescript/modules/ShoppingModule.d.ts +2 -2
  58. package/package.json +1 -1
  59. package/src/FWNavigator.tsx +12 -11
  60. package/src/FireworkSDK.ts +24 -20
  61. package/src/VideoShopping.ts +5 -17
  62. package/src/index.tsx +2 -15
  63. package/src/models/NewNativeContainerProps.ts +4 -0
  64. package/src/modules/FWNavigatorModule.ts +1 -1
  65. package/src/modules/FireworkSDKModule.ts +2 -1
  66. package/src/modules/ShoppingModule.ts +5 -2
  67. package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWCustomCTALinkContentContainerActivity.kt +0 -55
  68. package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWVideoShoppingCartActivity.kt +0 -43
  69. package/ios/Modules/FireworkSDKModule/FWCustomCTALinkContentContainerViewController.swift +0 -31
  70. package/lib/commonjs/components/CartContainer.js +0 -35
  71. package/lib/commonjs/components/CartContainer.js.map +0 -1
  72. package/lib/commonjs/components/CustomCTALinkContentContainer.js +0 -43
  73. package/lib/commonjs/components/CustomCTALinkContentContainer.js.map +0 -1
  74. package/lib/commonjs/components/NavigationContainer.js +0 -40
  75. package/lib/commonjs/components/NavigationContainer.js.map +0 -1
  76. package/lib/module/components/CartContainer.js +0 -18
  77. package/lib/module/components/CartContainer.js.map +0 -1
  78. package/lib/module/components/CustomCTALinkContentContainer.js +0 -26
  79. package/lib/module/components/CustomCTALinkContentContainer.js.map +0 -1
  80. package/lib/module/components/NavigationContainer.js +0 -23
  81. package/lib/module/components/NavigationContainer.js.map +0 -1
  82. package/lib/typescript/components/CartContainer.d.ts +0 -3
  83. package/lib/typescript/components/CustomCTALinkContentContainer.d.ts +0 -6
  84. package/lib/typescript/components/NavigationContainer.d.ts +0 -6
  85. package/src/components/CartContainer.tsx +0 -20
  86. package/src/components/CustomCTALinkContentContainer.tsx +0 -28
  87. package/src/components/NavigationContainer.tsx +0 -24
@@ -7,18 +7,10 @@
7
7
  <activity
8
8
  android:name="com.loopnow.fireworklibrary.PlaybackActivity"
9
9
  />
10
- <activity
11
- android:name="com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity"
12
- android:theme="@style/Theme.AppCompat.Light.NoActionBar"
13
- />
14
10
  <activity
15
11
  android:name="com.fireworksdk.bridge.reactnative.pages.FWContainerActivity"
16
12
  android:theme="@style/Theme.AppCompat.Light.NoActionBar"
17
13
  />
18
- <activity
19
- android:name="com.fireworksdk.bridge.reactnative.pages.FWCustomCTALinkContentContainerActivity"
20
- android:theme="@style/Theme.AppCompat.Light.NoActionBar"
21
- />
22
14
  <provider
23
15
  android:authorities="com.fireworksdk.bridge.reactnative"
24
16
  android:name=".reactnative.FWInitializationProvider"
@@ -1,9 +1,10 @@
1
1
  package com.fireworksdk.bridge.reactnative.models
2
2
 
3
3
  import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReadableMap
4
5
 
5
6
  interface FWNavigatorInterface {
6
7
 
7
- fun pushNativeContainer(callbackId: String?, promise: Promise)
8
+ fun pushNativeContainer(props: ReadableMap?, promise: Promise)
8
9
  fun popNativeContainer(promise: Promise)
9
10
  }
@@ -1,5 +1,6 @@
1
1
  package com.fireworksdk.bridge.reactnative.models
2
2
 
3
+ import com.facebook.react.bridge.Promise
3
4
  import com.facebook.react.bridge.ReadableArray
4
5
  import com.facebook.react.bridge.ReadableMap
5
6
 
@@ -9,8 +10,7 @@ interface FWVideoShoppingInterface {
9
10
  fun updateVideoProducts(productArray: ReadableArray?, videoId: String?)
10
11
  fun updateProductViewConfig(config: ReadableMap?, callbackId: Int?)
11
12
  fun updateAddToCartStatus(res: String?, tip: String?, callbackId: Int?)
12
- fun jumpToCartPage(callbackId: Int?)
13
- fun exitCartPage()
13
+ fun jumpToCartPage(callbackId: Int?, props: ReadableMap?)
14
14
  fun setCartIconVisible(visible: Boolean?)
15
15
  fun setCartItemCount(count: Int?)
16
16
  }
@@ -10,6 +10,7 @@ interface FireworkSDKInterface {
10
10
  fun setShareBaseURL(url: String?, promise: Promise)
11
11
  fun setAdBadgeConfiguration(config: ReadableMap?, promise: Promise)
12
12
  fun setCustomCTAClickEnabled(value: Boolean?)
13
- fun setCustomCTALinkContentRenderEnabled(value: Boolean?)
13
+ fun setCustomCTALinkContentPageRouteName(name: String?, promise: Promise)
14
+ fun setAppComponentName(name: String?, promise: Promise)
14
15
  fun setVideoPlaybackEventEnabled(value: Boolean?)
15
16
  }
@@ -5,9 +5,7 @@ import com.fireworksdk.bridge.reactnative.FWInitializationProvider
5
5
  import com.fireworksdk.bridge.reactnative.models.FWNavigatorInterface
6
6
  import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
7
7
  import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
8
- import com.fireworksdk.bridge.utils.FWDateUtils
9
8
  import com.fireworksdk.bridge.utils.FWLogUtils
10
- import java.util.*
11
9
 
12
10
 
13
11
  class FWNavigatorModule(
@@ -15,26 +13,8 @@ class FWNavigatorModule(
15
13
  ) : ReactContextBaseJavaModule(reactContext), FWNavigatorInterface {
16
14
 
17
15
  @ReactMethod
18
- override fun pushNativeContainer(callbackId: String?, promise: Promise) {
19
- FWLogUtils.d { "FWNavigatorModule pushNativeContainer: $callbackId" }
20
- val activity = FWInitializationProvider.INSTANCE.resumedActivity
21
-
22
- if (activity == null) {
23
- promise.resolve(false)
24
- return
25
- }
26
-
27
- FWEventUtils.sendLogMessageEvent(reactApplicationContext, "[Android] Enter pushNativeContainer ${FWDateUtils.getDateString(Date())}")
28
-
29
- UiThreadUtil.runOnUiThread {
30
-
31
- FWEventUtils.sendLogMessageEvent(reactApplicationContext, "[Android] Before Starting container activity ${FWDateUtils.getDateString(Date())}")
32
-
33
- activity.startActivity(FWContainerActivity.createIntent(activity, callbackId))
34
-
35
- FWEventUtils.sendLogMessageEvent(reactApplicationContext, "[Android] After Starting container activity ${FWDateUtils.getDateString(Date())}")
36
- }
37
- promise.resolve(true)
16
+ override fun pushNativeContainer(props: ReadableMap?, promise: Promise) {
17
+ FWEventUtils.pushNativeContainer(reactApplicationContext, props, promise)
38
18
  }
39
19
 
40
20
  @ReactMethod
@@ -47,6 +27,11 @@ class FWNavigatorModule(
47
27
  return
48
28
  }
49
29
 
30
+ if (activity !is FWContainerActivity) {
31
+ promise.resolve(false)
32
+ return
33
+ }
34
+
50
35
  UiThreadUtil.runOnUiThread {
51
36
  activity.finish()
52
37
  }
@@ -3,17 +3,16 @@ package com.fireworksdk.bridge.reactnative.module
3
3
  import android.app.Activity
4
4
  import com.facebook.react.bridge.*
5
5
  import com.fasterxml.jackson.core.type.TypeReference
6
- import com.fireworksdk.bridge.reactnative.FWInitializationProvider
7
6
  import com.loopnow.fireworklibrary.baya.Baya
8
7
  import com.loopnow.fireworklibrary.baya.UpdateCartStatus
9
8
  import com.fireworksdk.bridge.reactnative.models.FWVideoShoppingInterface
10
9
  import com.fireworksdk.bridge.models.FWVideoShoppingProduct
11
- import com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity
12
10
  import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
13
11
  import com.fireworksdk.bridge.utils.FWJsonUtils
14
12
  import com.fireworksdk.bridge.utils.FWLogUtils
15
13
  import com.loopnow.fireworklibrary.data.Product
16
14
  import com.loopnow.fireworklibrary.utils.Util
15
+ import kotlin.collections.HashMap
17
16
 
18
17
 
19
18
  class FWVideoShoppingModule(
@@ -112,26 +111,12 @@ class FWVideoShoppingModule(
112
111
  }
113
112
 
114
113
  @ReactMethod
115
- override fun jumpToCartPage(callbackId: Int?) {
116
- FWLogUtils.d { "FWVideoShoppingModule jumpToCartPage: $callbackId" }
114
+ override fun jumpToCartPage(callbackId: Int?, props: ReadableMap?) {
115
+ FWLogUtils.d { "FWVideoShoppingModule jumpToCartPage: $callbackId props: $props" }
117
116
  if (callbackId == null || cartClickHandler?.first != callbackId) {
118
117
  return
119
118
  }
120
- val activity = FWInitializationProvider.INSTANCE.resumedActivity ?: return
121
-
122
- UiThreadUtil.runOnUiThread {
123
- activity.startActivity(FWVideoShoppingCartActivity.createIntent(activity))
124
- }
125
- }
126
-
127
- @ReactMethod
128
- override fun exitCartPage() {
129
-
130
- val activity = FWInitializationProvider.INSTANCE.resumedActivity ?: return
131
-
132
- UiThreadUtil.runOnUiThread {
133
- activity.finish()
134
- }
119
+ FWEventUtils.pushNativeContainer(reactApplicationContext, props, null)
135
120
  }
136
121
 
137
122
  @ReactMethod
@@ -13,7 +13,7 @@ import com.facebook.react.bridge.ReactMethod
13
13
  import com.fireworksdk.bridge.models.FWAdBadgeConfigModel
14
14
  import com.fireworksdk.bridge.reactnative.FWInitializationProvider
15
15
  import com.fireworksdk.bridge.reactnative.models.FireworkSDKInterface
16
- import com.fireworksdk.bridge.reactnative.pages.FWCustomCTALinkContentContainerActivity
16
+ import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
17
17
  import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
18
18
  import com.loopnow.fireworklibrary.*
19
19
  import java.util.*
@@ -104,11 +104,6 @@ class FireworkSDKModule(
104
104
  FWVideoPlayerUtils.customCTAClickEnabled = value?:false
105
105
  }
106
106
 
107
- @ReactMethod
108
- override fun setCustomCTALinkContentRenderEnabled(value: Boolean?) {
109
- FWVideoPlayerUtils.customCTALinkContentRenderEnabled = value?:false
110
- }
111
-
112
107
  @ReactMethod
113
108
  override fun setVideoPlaybackEventEnabled(value: Boolean?) {
114
109
  FWVideoPlayerUtils.videoPlaybackEventEnabled = value?:false
@@ -180,12 +175,19 @@ class FireworkSDKModule(
180
175
 
181
176
  FWEventUtils.sendCustomCTAClickEvent(reactApplicationContext, actionUrl)
182
177
 
183
- if (FWVideoPlayerUtils.customCTALinkContentRenderEnabled) {
178
+ if (!appComponentName.isNullOrBlank() && !customCTALinkContentPageRouteName.isNullOrBlank()) {
184
179
  val activity = FWInitializationProvider.INSTANCE.resumedActivity
185
- activity?.startActivity(FWCustomCTALinkContentContainerActivity.createIntent(activity, actionUrl))
180
+
181
+ activity?.startActivity(FWContainerActivity.createIntent(activity, appComponentName,
182
+ hashMapOf(
183
+ "initialRouteName" to customCTALinkContentPageRouteName,
184
+ "initialParams" to hashMapOf("url" to actionUrl)
185
+ )
186
+ ))
187
+ return true
186
188
  }
187
189
 
188
- return FWVideoPlayerUtils.customCTAClickEnabled || FWVideoPlayerUtils.customCTALinkContentRenderEnabled
190
+ return FWVideoPlayerUtils.customCTAClickEnabled
189
191
  }
190
192
  }
191
193
  }
@@ -243,6 +245,18 @@ class FireworkSDKModule(
243
245
  })
244
246
  }
245
247
 
248
+ @ReactMethod
249
+ override fun setCustomCTALinkContentPageRouteName(name: String?, promise: Promise) {
250
+ customCTALinkContentPageRouteName = name
251
+ promise.resolve(Arguments.createMap())
252
+ }
253
+
254
+ @ReactMethod
255
+ override fun setAppComponentName(name: String?, promise: Promise) {
256
+ appComponentName = name
257
+ promise.resolve(Arguments.createMap())
258
+ }
259
+
246
260
  @ReactMethod
247
261
  fun addListener(eventName: String?, promise: Promise) {
248
262
  // Set up any upstream listeners or background tasks as necessary
@@ -261,4 +275,9 @@ class FireworkSDKModule(
261
275
  return "FireworkSDK"
262
276
  }
263
277
 
278
+ companion object {
279
+ var appComponentName: String? = null
280
+ var customCTALinkContentPageRouteName: String? = null
281
+ }
282
+
264
283
  }
@@ -8,6 +8,8 @@ import androidx.fragment.app.Fragment
8
8
  import com.facebook.react.ReactFragment
9
9
  import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
10
10
  import com.fireworksdk.bridge.R
11
+ import com.fireworksdk.bridge.utils.FWBundleUtils
12
+
11
13
 
12
14
  class FWContainerActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {
13
15
 
@@ -15,11 +17,12 @@ class FWContainerActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {
15
17
  super.onCreate(savedInstanceState)
16
18
  setContentView(R.layout.fw_bridge_fragment_container)
17
19
 
18
- val callbackId = intent.getStringExtra(KEY_CALLBACK_ID)
20
+ val componentName = intent.getStringExtra(KEY_COMPONENT_NAME)
21
+ val params = intent.getSerializableExtra(KEY_PARAMS) as HashMap<String, Any?>?
19
22
 
20
23
  val reactNativeFragment: Fragment = ReactFragment.Builder()
21
- .setComponentName(COMPONENT_NAME)
22
- .setLaunchOptions(getLaunchOptions(callbackId))
24
+ .setComponentName(componentName)
25
+ .setLaunchOptions(FWBundleUtils.mapToBundle(params))
23
26
  .build()
24
27
 
25
28
  supportFragmentManager
@@ -28,20 +31,29 @@ class FWContainerActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {
28
31
  .commit()
29
32
  }
30
33
 
31
- private fun getLaunchOptions(callbackId: String?) = Bundle().apply {
32
- if (!callbackId.isNullOrEmpty()) {
33
- putString(KEY_CALLBACK_ID, callbackId)
34
+ // https://github.com/facebook/react-native/issues/16026
35
+ private fun getLaunchOptions(params: HashMap<String, Any?>?) = Bundle().apply {
36
+ if (params != null) {
37
+ putBundle(KEY_PARAMS, FWBundleUtils.mapToBundle(params))
38
+
39
+ // val jsonString = FWJsonUtils.toJson(params)
40
+ // if (!jsonString.isNullOrBlank()) {
41
+ // val jsonObject = JSONObject(jsonString)
42
+ // val writableMap = FWDataUtils.convertJsonObjectToWritableMap(jsonObject)
43
+ // putSerializable(KEY_PARAMS, params)
44
+ // }
34
45
  }
35
46
  }
36
47
 
37
48
  companion object {
38
49
 
39
- private const val KEY_CALLBACK_ID = "callbackId"
40
- private const val COMPONENT_NAME = "FWNavigationContainer"
50
+ private const val KEY_PARAMS = "params"
51
+ private const val KEY_COMPONENT_NAME = "componentName"
41
52
 
42
- fun createIntent(activity: Activity, callbackId: String?): Intent {
53
+ fun createIntent(activity: Activity, componentName: String?, params: HashMap<String, Any?>?): Intent {
43
54
  val intent = Intent(activity, FWContainerActivity::class.java)
44
- intent.putExtra(KEY_CALLBACK_ID, callbackId)
55
+ intent.putExtra(KEY_COMPONENT_NAME, componentName)
56
+ intent.putExtra(KEY_PARAMS, params)
45
57
  intent.flags = Intent.FLAG_ACTIVITY_NO_ANIMATION
46
58
  activity.overridePendingTransition(0, 0)
47
59
  return intent
@@ -0,0 +1,119 @@
1
+ package com.fireworksdk.bridge.reactnative.utils
2
+ import com.facebook.react.bridge.*
3
+ import org.json.JSONArray
4
+ import org.json.JSONException
5
+ import org.json.JSONObject
6
+
7
+
8
+ object FWDataUtils {
9
+
10
+ @Throws(JSONException::class)
11
+ fun convertJsonObjectToWritableMap(jsonObject: JSONObject?): WritableMap? {
12
+ if (jsonObject == null) {
13
+ return null
14
+ }
15
+ val map: WritableMap = WritableNativeMap()
16
+ val iterator = jsonObject.keys()
17
+ while (iterator.hasNext()) {
18
+ val key = iterator.next()
19
+ when (val value = jsonObject[key]) {
20
+ is JSONObject -> {
21
+ map.putMap(key, convertJsonObjectToWritableMap(value))
22
+ }
23
+ is JSONArray -> {
24
+ map.putArray(key, convertJsonObjectToWritableArray(value))
25
+ }
26
+ is Boolean -> {
27
+ map.putBoolean(key, value)
28
+ }
29
+ is Int -> {
30
+ map.putInt(key, value)
31
+ }
32
+ is Double -> {
33
+ map.putDouble(key, value)
34
+ }
35
+ is String -> {
36
+ map.putString(key, value)
37
+ }
38
+ else -> {
39
+ map.putString(key, value.toString())
40
+ }
41
+ }
42
+ }
43
+ return map
44
+ }
45
+
46
+ @Throws(JSONException::class)
47
+ fun convertJsonObjectToWritableArray(jsonArray: JSONArray?): WritableArray? {
48
+ if (jsonArray == null) {
49
+ return null
50
+ }
51
+ val array: WritableArray = WritableNativeArray()
52
+ for (i in 0 until jsonArray.length()) {
53
+ when (val value = jsonArray[i]) {
54
+ is JSONObject -> {
55
+ array.pushMap(convertJsonObjectToWritableMap(value))
56
+ }
57
+ is JSONArray -> {
58
+ array.pushArray(convertJsonObjectToWritableArray(value))
59
+ }
60
+ is Boolean -> {
61
+ array.pushBoolean(value)
62
+ }
63
+ is Int -> {
64
+ array.pushInt(value)
65
+ }
66
+ is Double -> {
67
+ array.pushDouble(value)
68
+ }
69
+ is String -> {
70
+ array.pushString(value)
71
+ }
72
+ else -> {
73
+ array.pushString(value.toString())
74
+ }
75
+ }
76
+ }
77
+ return array
78
+ }
79
+
80
+ @Throws(JSONException::class)
81
+ fun convertReadableMapToJsonObject(readableMap: ReadableMap?): JSONObject? {
82
+ if (readableMap == null) {
83
+ return null
84
+ }
85
+ val `object` = JSONObject()
86
+ val iterator = readableMap.keySetIterator()
87
+ while (iterator.hasNextKey()) {
88
+ val key = iterator.nextKey()
89
+ when (readableMap.getType(key)) {
90
+ ReadableType.Null -> `object`.put(key, JSONObject.NULL)
91
+ ReadableType.Boolean -> `object`.put(key, readableMap.getBoolean(key))
92
+ ReadableType.Number -> `object`.put(key, readableMap.getDouble(key))
93
+ ReadableType.String -> `object`.put(key, readableMap.getString(key))
94
+ ReadableType.Map -> `object`.put(key, convertReadableMapToJsonObject(readableMap.getMap(key)))
95
+ ReadableType.Array -> `object`.put(key, convertReadableArrayToJsonObject(readableMap.getArray(key)))
96
+ }
97
+ }
98
+ return `object`
99
+ }
100
+
101
+ @Throws(JSONException::class)
102
+ fun convertReadableArrayToJsonObject(readableArray: ReadableArray?): JSONArray? {
103
+ if (readableArray == null) {
104
+ return null
105
+ }
106
+ val array = JSONArray()
107
+ for (i in 0 until readableArray.size()) {
108
+ when (readableArray.getType(i)) {
109
+ ReadableType.Null -> {}
110
+ ReadableType.Boolean -> array.put(readableArray.getBoolean(i))
111
+ ReadableType.Number -> array.put(readableArray.getDouble(i))
112
+ ReadableType.String -> array.put(readableArray.getString(i))
113
+ ReadableType.Map -> array.put(convertReadableMapToJsonObject(readableArray.getMap(i)))
114
+ ReadableType.Array -> array.put(convertReadableArrayToJsonObject(readableArray.getArray(i)))
115
+ }
116
+ }
117
+ return array
118
+ }
119
+ }
@@ -1,17 +1,52 @@
1
1
  package com.fireworksdk.bridge.reactnative.utils
2
2
 
3
3
  import android.util.Log
4
- import com.facebook.react.bridge.Arguments
5
- import com.facebook.react.bridge.ReactContext
6
- import com.facebook.react.bridge.WritableMap
4
+ import com.facebook.react.bridge.*
7
5
  import com.facebook.react.modules.core.DeviceEventManagerModule
8
6
  import com.facebook.react.uimanager.events.RCTEventEmitter
9
7
  import com.fireworksdk.bridge.models.*
8
+ import com.fireworksdk.bridge.reactnative.FWInitializationProvider
9
+ import com.fireworksdk.bridge.reactnative.module.FireworkSDKModule
10
+ import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
11
+ import com.fireworksdk.bridge.utils.FWDateUtils
10
12
  import com.fireworksdk.bridge.utils.FWLogUtils
11
13
  import com.loopnow.fireworklibrary.data.Product
14
+ import java.util.*
12
15
 
13
16
  object FWEventUtils {
14
17
 
18
+ fun pushNativeContainer(reactContext: ReactContext, props: ReadableMap?, promise: Promise?) {
19
+ FWLogUtils.d { "FWNavigatorModule pushNativeContainer: $props" }
20
+ val activity = FWInitializationProvider.INSTANCE.resumedActivity
21
+
22
+ if (activity == null) {
23
+ promise?.resolve(false)
24
+ return
25
+ }
26
+
27
+ sendLogMessageEvent(reactContext, "[Android] Enter pushNativeContainer ${
28
+ FWDateUtils.getDateString(
29
+ Date()
30
+ )}")
31
+
32
+ UiThreadUtil.runOnUiThread {
33
+
34
+ sendLogMessageEvent(reactContext, "[Android] Before Starting container activity ${
35
+ FWDateUtils.getDateString(
36
+ Date()
37
+ )}")
38
+
39
+ activity.startActivity(FWContainerActivity.createIntent(activity, FireworkSDKModule.appComponentName, props?.toHashMap()))
40
+
41
+ sendLogMessageEvent(reactContext, "[Android] After Starting container activity ${
42
+ FWDateUtils.getDateString(
43
+ Date()
44
+ )}")
45
+ }
46
+
47
+ promise?.resolve(true)
48
+ }
49
+
15
50
  fun sendInitSuccessEvent(reactContext: ReactContext) {
16
51
  sendEvent(reactContext, FWEventName.SDKIni.rawValue, Arguments.createMap())
17
52
  }
@@ -0,0 +1,86 @@
1
+ package com.fireworksdk.bridge.utils
2
+
3
+ import android.os.Bundle
4
+ import android.os.Parcelable
5
+
6
+
7
+ object FWBundleUtils {
8
+
9
+ fun mapToBundle(map: Map<String, Any?>?): Bundle? {
10
+ if (map == null) {
11
+ return null
12
+ }
13
+ val bundle = Bundle()
14
+ for ((key, value) in map) {
15
+ if (value is Double) {
16
+ bundle.putDouble(key, value)
17
+ } else if (value is Int) {
18
+ bundle.putInt(key, value)
19
+ } else if (value is String) {
20
+ bundle.putString(key, value)
21
+ } else if (value is Boolean) {
22
+ bundle.putBoolean(key, value)
23
+ } else if (value is List<*>) {
24
+ val list = value as List<Any>
25
+ val first = list[0]
26
+ if (first == null || first is Double) {
27
+ bundle.putDoubleArray(key, listToDoubleArray(list))
28
+ } else if (first is Int) {
29
+ bundle.putIntArray(key, listToIntArray(list))
30
+ } else if (first is String) {
31
+ bundle.putStringArray(key, listToStringArray(list))
32
+ } else if (first is Map<*, *>) {
33
+ bundle.putParcelableArrayList(key, listToParcelableArrayList(list))
34
+ }
35
+ } else if (value is Map<*, *>) {
36
+ bundle.putBundle(key, mapToBundle(value as Map<String, Any>))
37
+ }
38
+ }
39
+ return bundle
40
+ }
41
+
42
+ private fun listToDoubleArray(list: List<Any>?): DoubleArray? {
43
+ if (list == null) {
44
+ return null
45
+ }
46
+ val doubles = DoubleArray(list.size)
47
+ for (i in list.indices) {
48
+ doubles[i] = list[i] as Double
49
+ }
50
+ return doubles
51
+ }
52
+
53
+ private fun listToIntArray(list: List<Any>?): IntArray? {
54
+ if (list == null) {
55
+ return null
56
+ }
57
+ val integers = IntArray(list.size)
58
+ for (i in list.indices) {
59
+ integers[i] = list[i] as Int
60
+ }
61
+ return integers
62
+ }
63
+
64
+ private fun listToStringArray(list: List<Any>?): Array<String?>? {
65
+ if (list == null) {
66
+ return null
67
+ }
68
+ val strings = arrayOfNulls<String>(list.size)
69
+ for (i in list.indices) {
70
+ strings[i] = list[i].toString()
71
+ }
72
+ return strings
73
+ }
74
+
75
+ private fun listToParcelableArrayList(list: List<Any>?): ArrayList<Parcelable?>? {
76
+ if (list == null) {
77
+ return null
78
+ }
79
+ val arrayList: ArrayList<Parcelable?> = ArrayList()
80
+ for (item in list) {
81
+ val map = item as Map<String, Any>
82
+ arrayList.add(mapToBundle(map))
83
+ }
84
+ return arrayList
85
+ }
86
+ }
@@ -17,7 +17,6 @@ import com.loopnow.fireworklibrary.views.VideoFeedView
17
17
  object FWVideoPlayerUtils {
18
18
 
19
19
  var customCTAClickEnabled: Boolean = false
20
- var customCTALinkContentRenderEnabled: Boolean = false
21
20
  var videoPlaybackEventEnabled: Boolean = false
22
21
 
23
22
  private var hasAssignedLaunchAppWithMute = false
@@ -37,7 +37,6 @@
37
37
  8975239E2817DEF80070EBB6 /* FireworkSDKModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 897523832817DEF80070EBB6 /* FireworkSDKModule.m */; };
38
38
  8975239F2817DEF80070EBB6 /* LiveStreamModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 897523852817DEF80070EBB6 /* LiveStreamModule.swift */; };
39
39
  897523A02817DEF80070EBB6 /* LiveStreamModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 897523862817DEF80070EBB6 /* LiveStreamModule.m */; };
40
- 89BA1734283619FE00C2287A /* FWCustomCTALinkContentContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 89BA1733283619FE00C2287A /* FWCustomCTALinkContentContainerViewController.swift */; };
41
40
  /* End PBXBuildFile section */
42
41
 
43
42
  /* Begin PBXCopyFilesBuildPhase section */
@@ -86,7 +85,6 @@
86
85
  897523832817DEF80070EBB6 /* FireworkSDKModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FireworkSDKModule.m; sourceTree = "<group>"; };
87
86
  897523852817DEF80070EBB6 /* LiveStreamModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LiveStreamModule.swift; sourceTree = "<group>"; };
88
87
  897523862817DEF80070EBB6 /* LiveStreamModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LiveStreamModule.m; sourceTree = "<group>"; };
89
- 89BA1733283619FE00C2287A /* FWCustomCTALinkContentContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FWCustomCTALinkContentContainerViewController.swift; sourceTree = "<group>"; };
90
88
  /* End PBXFileReference section */
91
89
 
92
90
  /* Begin PBXFrameworksBuildPhase section */
@@ -214,7 +212,6 @@
214
212
  897523812817DEF80070EBB6 /* AdBadgeConfiguration.swift */,
215
213
  897523822817DEF80070EBB6 /* FireworkSDKModule+CTA.swift */,
216
214
  897523832817DEF80070EBB6 /* FireworkSDKModule.m */,
217
- 89BA1733283619FE00C2287A /* FWCustomCTALinkContentContainerViewController.swift */,
218
215
  );
219
216
  path = FireworkSDKModule;
220
217
  sourceTree = "<group>";
@@ -304,7 +301,6 @@
304
301
  8975239A2817DEF80070EBB6 /* FireworkSDKModule+EventTracking.swift in Sources */,
305
302
  8975239E2817DEF80070EBB6 /* FireworkSDKModule.m in Sources */,
306
303
  897523962817DEF80070EBB6 /* ProductInfoViewConfiguration.swift in Sources */,
307
- 89BA1734283619FE00C2287A /* FWCustomCTALinkContentContainerViewController.swift in Sources */,
308
304
  8975238D2817DEF80070EBB6 /* RCTConvert+VideoFeed.swift in Sources */,
309
305
  8975238C2817DEF80070EBB6 /* RCTConvert+Shopping.swift in Sources */,
310
306
  897523602817DEEE0070EBB6 /* VideoFeed.swift in Sources */,
@@ -8,16 +8,8 @@
8
8
  import UIKit
9
9
 
10
10
  class FWNavigatorContainerViewController: UIViewController {
11
- var callbackId: String!
12
-
13
- init(callbackId: String) {
14
- self.callbackId = callbackId
15
- super.init(nibName: nil, bundle: nil)
16
- }
17
-
18
- required init?(coder: NSCoder) {
19
- super.init(coder: coder)
20
- }
11
+ var moduleName: String = ""
12
+ var properties: [String: Any] = [:]
21
13
 
22
14
  override func viewDidLoad() {
23
15
  super.viewDidLoad()
@@ -25,7 +17,7 @@ class FWNavigatorContainerViewController: UIViewController {
25
17
  }
26
18
 
27
19
  private func loadContent() {
28
- let rctRootView = RCTRootView.init(bridge: RCTBridge.current(), moduleName: "FWNavigationContainer", initialProperties: ["callbackId": callbackId ?? ""])
20
+ let rctRootView = RCTRootView.init(bridge: RCTBridge.current(), moduleName: moduleName, initialProperties: properties)
29
21
  view.addSubview(rctRootView)
30
22
  rctRootView.translatesAutoresizingMaskIntoConstraints = false
31
23
 
@@ -2,7 +2,7 @@
2
2
  // FWNavigatorModule.m
3
3
  // react-native-firework-sdk
4
4
  //
5
- // Created by 熊韦华 on 2022/4/22.
5
+ // Created by Big Bear Xiong on 2022/4/22.
6
6
  //
7
7
 
8
8
  // The FireworkNavigatorModule exposes instances of Objective-C (native) classes to JavaScript (JS) as JS objects
@@ -11,7 +11,7 @@
11
11
 
12
12
  @interface RCT_EXTERN_REMAP_MODULE(FWNavigatorModule, FWNavigatorModule, NSObject)
13
13
 
14
- RCT_EXTERN_METHOD(pushNativeContainer:(NSString *)callbackId resolver:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
14
+ RCT_EXTERN_METHOD(pushNativeContainer:(NSDictionary *)props resolver:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
15
15
  RCT_EXTERN_METHOD(popNativeContainer:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
16
16
 
17
17
  @end