react-native-firework-sdk 1.1.0 → 1.2.0-beta.10

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 (147) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/gradlew +0 -0
  3. package/android/src/main/AndroidManifest.xml +6 -1
  4. package/android/src/main/java/com/fireworksdk/bridge/{reactnative/FireworkSDKPackage.kt → FireworkSDKPackage.kt} +4 -2
  5. package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +19 -6
  6. package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +1 -0
  7. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModel.kt +2 -1
  8. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModel.kt +1 -0
  9. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedSource.kt +1 -0
  10. package/android/src/main/java/com/fireworksdk/bridge/reactnative/FWInitializationProvider.kt +99 -0
  11. package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +6 -0
  12. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt +10 -0
  13. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +2 -2
  14. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt +3 -1
  15. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +53 -0
  16. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +4 -15
  17. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +41 -7
  18. package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWContainerActivity.kt +66 -0
  19. package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWDataUtils.kt +119 -0
  20. package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +50 -3
  21. package/android/src/main/java/com/fireworksdk/bridge/utils/FWBundleUtils.kt +86 -0
  22. package/android/src/main/java/com/fireworksdk/bridge/utils/FWDateUtils.kt +15 -0
  23. package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +12 -2
  24. package/android/src/main/res/layout/fw_bridge_fragment_container.xml +8 -0
  25. package/ios/Components/VideoFeed.swift +6 -25
  26. package/ios/Components/VideoFeedManager.m +1 -0
  27. package/ios/FireworkSdk.xcodeproj/project.pbxproj +202 -18
  28. package/ios/Models/NativeToRN/FireworkEventName.swift +1 -0
  29. package/ios/Models/RNToNative/RCTConvert+FireworkSDKModule.swift +0 -20
  30. package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +2 -1
  31. package/ios/Modules/FWNavigatorModule/FWNavigatorContainerViewController.swift +32 -0
  32. package/ios/Modules/FWNavigatorModule/FWNavigatorModule.m +17 -0
  33. package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +89 -0
  34. package/ios/Modules/FWNavigatorModule/FWNavigatorProtocol.swift +13 -0
  35. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +24 -1
  36. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +3 -1
  37. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +51 -31
  38. package/ios/Modules/Shopping/CartViewController.swift +6 -1
  39. package/ios/Modules/Shopping/ShoppingModule.m +1 -2
  40. package/ios/Modules/Shopping/ShoppingModule.swift +10 -12
  41. package/lib/commonjs/FWNavigator.js +66 -0
  42. package/lib/commonjs/FWNavigator.js.map +1 -0
  43. package/lib/commonjs/FireworkSDK.js +59 -5
  44. package/lib/commonjs/FireworkSDK.js.map +1 -1
  45. package/lib/commonjs/LiveStream.js +2 -2
  46. package/lib/commonjs/LiveStream.js.map +1 -1
  47. package/lib/commonjs/VideoShopping.js +4 -18
  48. package/lib/commonjs/VideoShopping.js.map +1 -1
  49. package/lib/commonjs/components/FWVideoFeed.js.map +1 -1
  50. package/lib/commonjs/components/VideoFeed.js +33 -1
  51. package/lib/commonjs/components/VideoFeed.js.map +1 -1
  52. package/lib/commonjs/constants/FWErrorMessage.js.map +1 -1
  53. package/lib/commonjs/index.js +10 -8
  54. package/lib/commonjs/index.js.map +1 -1
  55. package/lib/commonjs/models/FWEventName.js +3 -2
  56. package/lib/commonjs/models/FWEventName.js.map +1 -1
  57. package/lib/commonjs/models/NewNativeContainerProps.js +2 -0
  58. package/lib/commonjs/models/{AdConfig.js.map → NewNativeContainerProps.js.map} +0 -0
  59. package/lib/commonjs/models/VideoFeedSource.js +0 -4
  60. package/lib/commonjs/modules/FWNavigatorModule.js +22 -0
  61. package/lib/commonjs/modules/FWNavigatorModule.js.map +1 -0
  62. package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
  63. package/lib/commonjs/modules/LiveStreamModule.js.map +1 -1
  64. package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
  65. package/lib/commonjs/utils/FWLoggerUtil.js +45 -0
  66. package/lib/commonjs/utils/FWLoggerUtil.js.map +1 -0
  67. package/lib/module/FWNavigator.js +49 -0
  68. package/lib/module/FWNavigator.js.map +1 -0
  69. package/lib/module/FireworkSDK.js +54 -5
  70. package/lib/module/FireworkSDK.js.map +1 -1
  71. package/lib/module/LiveStream.js +4 -4
  72. package/lib/module/LiveStream.js.map +1 -1
  73. package/lib/module/VideoShopping.js +4 -18
  74. package/lib/module/VideoShopping.js.map +1 -1
  75. package/lib/module/components/FWVideoFeed.js +1 -1
  76. package/lib/module/components/FWVideoFeed.js.map +1 -1
  77. package/lib/module/components/VideoFeed.js +33 -1
  78. package/lib/module/components/VideoFeed.js.map +1 -1
  79. package/lib/module/constants/FWErrorMessage.js.map +1 -1
  80. package/lib/module/index.js +3 -5
  81. package/lib/module/index.js.map +1 -1
  82. package/lib/module/models/FWEventName.js +3 -2
  83. package/lib/module/models/FWEventName.js.map +1 -1
  84. package/lib/module/models/NewNativeContainerProps.js +2 -0
  85. package/lib/module/models/{AdConfig.js.map → NewNativeContainerProps.js.map} +0 -0
  86. package/lib/module/models/VideoFeedSource.js +1 -1
  87. package/lib/module/modules/FWNavigatorModule.js +13 -0
  88. package/lib/module/modules/FWNavigatorModule.js.map +1 -0
  89. package/lib/module/modules/FireworkSDKModule.js.map +1 -1
  90. package/lib/module/modules/LiveStreamModule.js.map +1 -1
  91. package/lib/module/modules/ShoppingModule.js.map +1 -1
  92. package/lib/module/utils/FWLoggerUtil.js +36 -0
  93. package/lib/module/utils/FWLoggerUtil.js.map +1 -0
  94. package/lib/typescript/FWNavigator.d.ts +24 -0
  95. package/lib/typescript/FireworkSDK.d.ts +21 -4
  96. package/lib/typescript/LiveStream.d.ts +1 -1
  97. package/lib/typescript/VideoShopping.d.ts +2 -9
  98. package/lib/typescript/components/VideoFeed.d.ts +8 -1
  99. package/lib/typescript/constants/FWErrorMessage.d.ts +1 -1
  100. package/lib/typescript/index.d.ts +6 -5
  101. package/lib/typescript/models/FWEventName.d.ts +4 -3
  102. package/lib/typescript/models/FeedItemDetails.d.ts +1 -1
  103. package/lib/typescript/models/NewNativeContainerProps.d.ts +6 -0
  104. package/lib/typescript/models/VideoFeedConfiguration.d.ts +4 -0
  105. package/lib/typescript/models/VideoFeedSource.d.ts +1 -2
  106. package/lib/typescript/modules/FWNavigatorModule.d.ts +11 -0
  107. package/lib/typescript/modules/FireworkSDKModule.d.ts +5 -4
  108. package/lib/typescript/modules/ShoppingModule.d.ts +2 -2
  109. package/lib/typescript/utils/FWLoggerUtil.d.ts +6 -0
  110. package/package.json +3 -1
  111. package/react-native-firework-sdk.podspec +1 -1
  112. package/src/FWNavigator.tsx +49 -0
  113. package/src/FireworkSDK.ts +57 -8
  114. package/src/LiveStream.ts +9 -7
  115. package/src/VideoShopping.ts +10 -21
  116. package/src/components/FWVideoFeed.tsx +5 -5
  117. package/src/components/VideoFeed.tsx +48 -14
  118. package/src/constants/FWErrorMessage.ts +1 -3
  119. package/src/index.tsx +9 -10
  120. package/src/models/AdBadgeConfiguration.ts +1 -1
  121. package/src/models/FWError.ts +1 -1
  122. package/src/models/FWEventName.ts +3 -2
  123. package/src/models/FWEvents.ts +1 -1
  124. package/src/models/FeedItemDetails.ts +2 -2
  125. package/src/models/LiveStreamEventDetails.ts +1 -1
  126. package/src/models/LiveStreamMessageDetails.ts +1 -1
  127. package/src/models/NewNativeContainerProps.ts +4 -0
  128. package/src/models/VideoFeedConfiguration.ts +6 -2
  129. package/src/models/VideoFeedSource.ts +6 -2
  130. package/src/models/VideoPlayerConfiguration.ts +2 -2
  131. package/src/modules/FWNavigatorModule.ts +22 -0
  132. package/src/modules/FireworkSDKModule.ts +5 -6
  133. package/src/modules/LiveStreamModule.ts +1 -5
  134. package/src/modules/ShoppingModule.ts +5 -2
  135. package/src/utils/FWLoggerUtil.ts +40 -0
  136. package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWVideoShoppingCartActivity.kt +0 -43
  137. package/ios/Modules/FireworkSDKModule/MobileADConfiguration.swift +0 -17
  138. package/lib/commonjs/components/CartContainer.js +0 -35
  139. package/lib/commonjs/components/CartContainer.js.map +0 -1
  140. package/lib/commonjs/models/AdConfig.js +0 -2
  141. package/lib/module/components/CartContainer.js +0 -18
  142. package/lib/module/components/CartContainer.js.map +0 -1
  143. package/lib/module/models/AdConfig.js +0 -2
  144. package/lib/typescript/components/CartContainer.d.ts +0 -3
  145. package/lib/typescript/models/AdConfig.d.ts +0 -10
  146. package/src/components/CartContainer.tsx +0 -20
  147. package/src/models/AdConfig.ts +0 -10
@@ -168,7 +168,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
168
168
  dependencies {
169
169
 
170
170
  // optional 1: firework sdk release verison
171
- def firework_sdk_version = 'v5.11.2'
171
+ def firework_sdk_version = 'v5.12.2'
172
172
  implementation "com.github.loopsocial:firework_sdk:$firework_sdk_version"
173
173
 
174
174
  // optional 2: firework sdk local version,
package/android/gradlew CHANGED
File without changes
@@ -8,9 +8,14 @@
8
8
  android:name="com.loopnow.fireworklibrary.PlaybackActivity"
9
9
  />
10
10
  <activity
11
- android:name="com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity"
11
+ android:name="com.fireworksdk.bridge.reactnative.pages.FWContainerActivity"
12
12
  android:theme="@style/Theme.AppCompat.Light.NoActionBar"
13
13
  />
14
+ <provider
15
+ android:authorities="com.fireworksdk.bridge.reactnative"
16
+ android:name=".reactnative.FWInitializationProvider"
17
+ android:exported="false"
18
+ />
14
19
  <meta-data
15
20
  android:name="com.google.android.gms.ads.AD_MANAGER_APP"
16
21
  android:value="true" />
@@ -1,4 +1,4 @@
1
- package com.fireworksdk.bridge.reactnative
1
+ package com.fireworksdk.bridge
2
2
 
3
3
  import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
@@ -6,6 +6,7 @@ import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.uimanager.ViewManager
7
7
  import com.fireworksdk.bridge.reactnative.manager.FWVideoFeedManager
8
8
  import com.fireworksdk.bridge.reactnative.module.FWLiveStreamModule
9
+ import com.fireworksdk.bridge.reactnative.module.FWNavigatorModule
9
10
  import com.fireworksdk.bridge.reactnative.module.FWVideoShoppingModule
10
11
  import com.fireworksdk.bridge.reactnative.module.FireworkSDKModule
11
12
 
@@ -15,7 +16,8 @@ class FireworkSDKPackage : ReactPackage {
15
16
  return listOf(
16
17
  FireworkSDKModule(reactContext),
17
18
  FWVideoShoppingModule(reactContext),
18
- FWLiveStreamModule(reactContext)
19
+ FWLiveStreamModule(reactContext),
20
+ FWNavigatorModule(reactContext)
19
21
  )
20
22
  }
21
23
 
@@ -40,6 +40,7 @@ class FWVideoFeed(
40
40
  videoFeedPropsModel.mode = props.mode
41
41
  videoFeedPropsModel.videoFeedConfiguration = props.videoFeedConfiguration
42
42
  videoFeedPropsModel.videoPlayerConfiguration = props.videoPlayerConfiguration
43
+ videoFeedPropsModel.dynamicContentParameters = props.dynamicContentParameters
43
44
  }
44
45
  setData()
45
46
  }
@@ -69,6 +70,11 @@ class FWVideoFeed(
69
70
  setData()
70
71
  }
71
72
 
73
+ fun setDynamicContentParametersProps(dynamicContentParameters: HashMap<String, List<String>>?) {
74
+ videoFeedPropsModel.dynamicContentParameters = dynamicContentParameters
75
+ setData()
76
+ }
77
+
72
78
  fun setVideoFeedConfigProps(config: FWVideoFeedConfigModel?) {
73
79
  videoFeedPropsModel.videoFeedConfiguration = config
74
80
  setData()
@@ -87,6 +93,7 @@ class FWVideoFeed(
87
93
  private fun setData() {
88
94
  val source = videoFeedPropsModel.source
89
95
  val mode = videoFeedPropsModel.mode
96
+ val dynamicContentParameters = videoFeedPropsModel.dynamicContentParameters
90
97
  val channel = videoFeedPropsModel.channel
91
98
  val playlist = videoFeedPropsModel.playlist
92
99
  val playlistGroup = videoFeedPropsModel.playlistGroup
@@ -100,14 +107,17 @@ class FWVideoFeed(
100
107
  FWVideoFeedSource.PlaylistGroup.rawValue -> {
101
108
  setPlaylistGroupFeed(mode, playlistGroup, videoFeedConfiguration, videoPlayerConfiguration)
102
109
  }
110
+ FWVideoFeedSource.DynamicContent.rawValue -> {
111
+ setFeed(mode, channel, playlist, FeedType.DYNAMIC_CONTENT, dynamicContentParameters, videoFeedConfiguration, videoPlayerConfiguration)
112
+ }
103
113
  FWVideoFeedSource.Playlist.rawValue -> {
104
- setFeed(mode, channel, playlist, FeedType.PLAYLIST, videoFeedConfiguration, videoPlayerConfiguration)
114
+ setFeed(mode, channel, playlist, FeedType.PLAYLIST, null, videoFeedConfiguration, videoPlayerConfiguration)
105
115
  }
106
116
  FWVideoFeedSource.Channel.rawValue -> {
107
- setFeed(mode, channel, null, FeedType.CHANNEL, videoFeedConfiguration, videoPlayerConfiguration)
117
+ setFeed(mode, channel, null, FeedType.CHANNEL, null, videoFeedConfiguration, videoPlayerConfiguration)
108
118
  }
109
119
  else -> {
110
- setFeed(mode, null, null, FeedType.DISCOVER, videoFeedConfiguration, videoPlayerConfiguration)
120
+ setFeed(mode, null, null, FeedType.DISCOVER, null, videoFeedConfiguration, videoPlayerConfiguration)
111
121
  }
112
122
  }
113
123
  }
@@ -115,6 +125,7 @@ class FWVideoFeed(
115
125
  private fun setFeed(
116
126
  mode: String?,
117
127
  channelId: String?, playlistId: String?, feedType: FeedType?,
128
+ dynamicContentParameters: HashMap<String, List<String>>?,
118
129
  videoFeedConfiguration: FWVideoFeedConfigModel?,
119
130
  videoPlayerConfiguration: FWVideoPlayerConfigModel?,
120
131
  ) {
@@ -133,7 +144,9 @@ class FWVideoFeed(
133
144
  }
134
145
 
135
146
  // set channel playlistId feedType
136
- if (feedType == FeedType.CHANNEL && !channelId.isNullOrBlank()) {
147
+ if (feedType == FeedType.DYNAMIC_CONTENT && !channelId.isNullOrBlank()) {
148
+ videoFeedView?.setDynamicContent(channelId, dynamicContentParameters?:hashMapOf())
149
+ } else if (feedType == FeedType.CHANNEL && !channelId.isNullOrBlank()) {
137
150
  videoFeedView?.setFeed(channelId, null, FeedType.CHANNEL)
138
151
  } else if (feedType == FeedType.PLAYLIST && !channelId.isNullOrBlank() && !playlistId.isNullOrBlank()) {
139
152
  videoFeedView?.setFeed(channelId, playlistId, FeedType.PLAYLIST)
@@ -142,7 +155,7 @@ class FWVideoFeed(
142
155
  }
143
156
 
144
157
  // set Feed Configuration
145
- FWVideoPlayerUtils.setVideoFeedConfig(videoFeedView, videoFeedConfiguration)
158
+ FWVideoPlayerUtils.setVideoFeedConfig(context, videoFeedView, videoFeedConfiguration)
146
159
  // set Player Configuration
147
160
  FWVideoPlayerUtils.setVideoPlayerConfig(videoPlayerConfiguration)
148
161
  }
@@ -175,7 +188,7 @@ class FWVideoFeed(
175
188
  }
176
189
 
177
190
  // set Feed Configuration
178
- FWVideoPlayerUtils.setPlaylistGroupFeedConfig(playlistGroupFeedView, videoFeedConfiguration)
191
+ FWVideoPlayerUtils.setPlaylistGroupFeedConfig(context, playlistGroupFeedView, videoFeedConfiguration)
179
192
  // set Player Configuration
180
193
  FWVideoPlayerUtils.setVideoPlayerConfig(videoPlayerConfiguration)
181
194
  }
@@ -7,6 +7,7 @@ enum class FWEventName(val rawValue: String) {
7
7
  VideoFeedClick("fw:video-feed-click"),
8
8
  LiveStream("fw:livestream"),
9
9
  LiveStreamChat("fw:livestream-chat"),
10
+ LogMessage("fw:log-message")
10
11
  }
11
12
 
12
13
  enum class FWSDKInitSubEventName(val rawValue: String) {
@@ -10,7 +10,8 @@ data class FWVideoFeedConfigModel(
10
10
  var title: FWTitleModel? = null,
11
11
  var titlePosition: String? = null,
12
12
  var playIcon: FWPlayIconModel? = null,
13
- var showAdBadge: Boolean? = null
13
+ var showAdBadge: Boolean? = null,
14
+ var customLayoutName: String? = null
14
15
  ) : Parcelable {
15
16
 
16
17
  @Parcelize
@@ -15,4 +15,5 @@ data class FWVideoFeedPropsModel(
15
15
  var mode: String? = null,
16
16
  var videoFeedConfiguration: FWVideoFeedConfigModel? = null,
17
17
  var videoPlayerConfiguration: FWVideoPlayerConfigModel? = null,
18
+ var dynamicContentParameters: HashMap<String, List<String>>? = null,
18
19
  ) : Parcelable
@@ -4,5 +4,6 @@ enum class FWVideoFeedSource(val rawValue: String) {
4
4
  Discover("discover"),
5
5
  Channel("channel"),
6
6
  Playlist("playlist"),
7
+ DynamicContent("dynamicContent"),
7
8
  PlaylistGroup("playlistGroup"),
8
9
  }
@@ -0,0 +1,99 @@
1
+ package com.fireworksdk.bridge.reactnative
2
+
3
+ import android.app.Activity
4
+ import android.app.Application
5
+ import android.content.ContentProvider
6
+ import android.content.ContentValues
7
+ import android.database.Cursor
8
+ import android.net.Uri
9
+ import android.os.Bundle
10
+ import com.fireworksdk.bridge.models.weakProperty
11
+ import com.fireworksdk.bridge.utils.FWLogUtils
12
+
13
+ class FWInitializationProvider: ContentProvider() {
14
+
15
+ var application: Application? = null
16
+ var resumedActivity by weakProperty<Activity?>()
17
+
18
+ override fun onCreate(): Boolean {
19
+ sInstance = this
20
+ val context = context
21
+ if (context != null) {
22
+ // Many Initializer's expect the `applicationContext` to be non-null. This
23
+ // typically happens when `android:sharedUid` is used. In such cases, we postpone
24
+ // initialization altogether, and rely on lazy init.
25
+ // More context: b/196959015
26
+ val applicationContext = context.applicationContext as Application?
27
+ application = applicationContext
28
+
29
+ if (applicationContext != null) {
30
+ applicationContext.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
31
+ override fun onActivityCreated(activity: Activity, bundle: Bundle?) {
32
+ }
33
+
34
+ override fun onActivityStarted(activity: Activity) {
35
+ }
36
+
37
+ override fun onActivityResumed(activity: Activity) {
38
+ resumedActivity = activity
39
+ }
40
+
41
+ override fun onActivityPaused(activity: Activity) {
42
+ if (resumedActivity == activity) {
43
+ resumedActivity = null
44
+ }
45
+ }
46
+
47
+ override fun onActivityStopped(activity: Activity) {
48
+ }
49
+
50
+ override fun onActivitySaveInstanceState(activity: Activity, bundle: Bundle) {
51
+ }
52
+
53
+ override fun onActivityDestroyed(activity: Activity) {
54
+ }
55
+
56
+ })
57
+
58
+ } else {
59
+ FWLogUtils.w {"Deferring initialization because `applicationContext` is null."}
60
+ }
61
+ } else {
62
+ throw Exception("Context cannot be null")
63
+ }
64
+ return true
65
+ }
66
+
67
+ override fun query(
68
+ p0: Uri,
69
+ p1: Array<out String>?,
70
+ p2: String?,
71
+ p3: Array<out String>?,
72
+ p4: String?
73
+ ): Cursor? {
74
+ throw IllegalStateException("Not allowed.")
75
+ }
76
+
77
+ override fun getType(p0: Uri): String? {
78
+ throw IllegalStateException("Not allowed.")
79
+ }
80
+
81
+ override fun insert(p0: Uri, p1: ContentValues?): Uri? {
82
+ throw IllegalStateException("Not allowed.")
83
+ }
84
+
85
+ override fun delete(p0: Uri, p1: String?, p2: Array<out String>?): Int {
86
+ throw IllegalStateException("Not allowed.")
87
+ }
88
+
89
+ override fun update(p0: Uri, p1: ContentValues?, p2: String?, p3: Array<out String>?): Int {
90
+ throw IllegalStateException("Not allowed.")
91
+ }
92
+
93
+ companion object {
94
+ private lateinit var sInstance: FWInitializationProvider
95
+
96
+ val INSTANCE: FWInitializationProvider
97
+ get() = sInstance
98
+ }
99
+ }
@@ -133,6 +133,12 @@ class FWVideoFeedManager : SimpleViewManager<FWVideoFeed>() {
133
133
  view.setModeProps(mode)
134
134
  }
135
135
 
136
+ @ReactProp(name = "dynamicContentParameters")
137
+ fun setDynamicContentParameters(view: FWVideoFeed, parameters: ReadableMap?) {
138
+ val parametersMap = parameters?.toHashMap() as? HashMap<String, List<String>>
139
+ view.setDynamicContentParametersProps(parametersMap)
140
+ }
141
+
136
142
  @ReactProp(name = "videoFeedConfiguration")
137
143
  fun setVideoFeedConfig(view: FWVideoFeed, config: ReadableMap?) {
138
144
  val configMap = config?.toHashMap()
@@ -0,0 +1,10 @@
1
+ package com.fireworksdk.bridge.reactnative.models
2
+
3
+ import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReadableMap
5
+
6
+ interface FWNavigatorInterface {
7
+
8
+ fun pushNativeContainer(props: ReadableMap?, promise: Promise)
9
+ fun popNativeContainer(promise: Promise)
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
  }
@@ -5,10 +5,12 @@ import com.facebook.react.bridge.ReadableMap
5
5
 
6
6
  interface FireworkSDKInterface {
7
7
 
8
- fun init(userId: String?, adConfig: ReadableMap?)
8
+ fun init(userId: String?)
9
9
  fun openVideoPlayer(url: String, config: ReadableMap?)
10
10
  fun setShareBaseURL(url: String?, promise: Promise)
11
11
  fun setAdBadgeConfiguration(config: ReadableMap?, promise: Promise)
12
12
  fun setCustomCTAClickEnabled(value: Boolean?)
13
+ fun setCustomCTALinkContentPageRouteName(name: String?, promise: Promise)
14
+ fun setAppComponentName(name: String?, promise: Promise)
13
15
  fun setVideoPlaybackEventEnabled(value: Boolean?)
14
16
  }
@@ -0,0 +1,53 @@
1
+ package com.fireworksdk.bridge.reactnative.module
2
+
3
+ import com.facebook.react.bridge.*
4
+ import com.fireworksdk.bridge.reactnative.FWInitializationProvider
5
+ import com.fireworksdk.bridge.reactnative.models.FWNavigatorInterface
6
+ import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
7
+ import com.fireworksdk.bridge.utils.FWLogUtils
8
+
9
+
10
+ class FWNavigatorModule(
11
+ reactContext: ReactApplicationContext
12
+ ) : ReactContextBaseJavaModule(reactContext), FWNavigatorInterface {
13
+
14
+ @ReactMethod
15
+ override fun pushNativeContainer(props: ReadableMap?, promise: Promise) {
16
+ FWEventUtils.pushNativeContainer(reactApplicationContext, props, promise)
17
+ }
18
+
19
+ @ReactMethod
20
+ override fun popNativeContainer(promise: Promise) {
21
+ FWLogUtils.d { "FWNavigatorModule popNativeContainer" }
22
+
23
+ val activity = FWInitializationProvider.INSTANCE.resumedActivity
24
+ if (activity == null) {
25
+ promise.resolve(false)
26
+ return
27
+ }
28
+
29
+ UiThreadUtil.runOnUiThread {
30
+ activity.finish()
31
+ }
32
+ promise.resolve(true)
33
+ }
34
+
35
+ @ReactMethod
36
+ fun addListener(eventName: String?, promise: Promise) {
37
+ // Set up any upstream listeners or background tasks as necessary
38
+ FWLogUtils.d { "addListener: $eventName" }
39
+ promise.resolve(Arguments.createMap())
40
+ }
41
+
42
+ @ReactMethod
43
+ fun removeListeners(count: Int?, promise: Promise) {
44
+ // Remove upstream listeners, stop unnecessary background tasks
45
+ FWLogUtils.d { "removeListeners: $count" }
46
+ promise.resolve(Arguments.createMap())
47
+ }
48
+
49
+ override fun getName(): String {
50
+ return "FWNavigatorModule"
51
+ }
52
+
53
+ }
@@ -7,12 +7,12 @@ import com.loopnow.fireworklibrary.baya.Baya
7
7
  import com.loopnow.fireworklibrary.baya.UpdateCartStatus
8
8
  import com.fireworksdk.bridge.reactnative.models.FWVideoShoppingInterface
9
9
  import com.fireworksdk.bridge.models.FWVideoShoppingProduct
10
- import com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity
11
10
  import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
12
11
  import com.fireworksdk.bridge.utils.FWJsonUtils
13
12
  import com.fireworksdk.bridge.utils.FWLogUtils
14
13
  import com.loopnow.fireworklibrary.data.Product
15
14
  import com.loopnow.fireworklibrary.utils.Util
15
+ import kotlin.collections.HashMap
16
16
 
17
17
 
18
18
  class FWVideoShoppingModule(
@@ -111,23 +111,12 @@ class FWVideoShoppingModule(
111
111
  }
112
112
 
113
113
  @ReactMethod
114
- override fun jumpToCartPage(callbackId: Int?) {
115
- FWLogUtils.d { "FWVideoShoppingModule jumpToCartPage: $callbackId" }
114
+ override fun jumpToCartPage(callbackId: Int?, props: ReadableMap?) {
115
+ FWLogUtils.d { "FWVideoShoppingModule jumpToCartPage: $callbackId props: $props" }
116
116
  if (callbackId == null || cartClickHandler?.first != callbackId) {
117
117
  return
118
118
  }
119
- val activity = cartClickHandler?.second ?: return
120
-
121
- UiThreadUtil.runOnUiThread {
122
- activity.startActivity(FWVideoShoppingCartActivity.createIntent(activity))
123
- }
124
- }
125
-
126
- @ReactMethod
127
- override fun exitCartPage() {
128
- UiThreadUtil.runOnUiThread {
129
- currentActivity?.finish()
130
- }
119
+ FWEventUtils.pushNativeContainer(reactApplicationContext, props, null)
131
120
  }
132
121
 
133
122
  @ReactMethod
@@ -11,9 +11,12 @@ import com.fireworksdk.bridge.utils.*
11
11
  import org.json.JSONObject
12
12
  import com.facebook.react.bridge.ReactMethod
13
13
  import com.fireworksdk.bridge.models.FWAdBadgeConfigModel
14
+ import com.fireworksdk.bridge.reactnative.FWInitializationProvider
14
15
  import com.fireworksdk.bridge.reactnative.models.FireworkSDKInterface
16
+ import com.fireworksdk.bridge.reactnative.pages.FWContainerActivity
15
17
  import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
16
18
  import com.loopnow.fireworklibrary.*
19
+ import java.util.*
17
20
 
18
21
 
19
22
  class FireworkSDKModule(
@@ -35,8 +38,10 @@ class FireworkSDKModule(
35
38
  * If id passed is not unique, it will affect the quality of content recommended to the user.
36
39
  */
37
40
  @ReactMethod
38
- override fun init(userId: String?, adConfig: ReadableMap?) {
39
- init(userId)
41
+ override fun init(userId: String?) {
42
+ initSdk(userId)
43
+
44
+ handleCustomCTAClick()
40
45
  }
41
46
 
42
47
  /**
@@ -97,7 +102,6 @@ class FireworkSDKModule(
97
102
  @ReactMethod
98
103
  override fun setCustomCTAClickEnabled(value: Boolean?) {
99
104
  FWVideoPlayerUtils.customCTAClickEnabled = value?:false
100
- handleCustomCTAClick()
101
105
  }
102
106
 
103
107
  @ReactMethod
@@ -106,7 +110,7 @@ class FireworkSDKModule(
106
110
  handleVideoPlaybackEvent()
107
111
  }
108
112
 
109
- private fun init(userId: String?) {
113
+ private fun initSdk(userId: String?) {
110
114
  val clientId = getAppid()
111
115
  if (clientId.isNullOrBlank()) {
112
116
  val errorMsg = "The appid is invalid"
@@ -163,13 +167,26 @@ class FireworkSDKModule(
163
167
  }
164
168
 
165
169
  private fun handleCustomCTAClick() {
166
- if (!FWVideoPlayerUtils.customCTAClickEnabled) {
167
- return
168
- }
169
170
  FwSDK.ctaClickHandler = object: FwSDK.CtaClickHandler {
170
171
  override fun ctaClicked(label: String, actionUrl: String?): Boolean {
171
172
  FWLogUtils.d { "ctaClicked" }
173
+
174
+ FWEventUtils.sendLogMessageEvent(reactApplicationContext, "[Android] Receive CustomCTAClick event ${FWDateUtils.getDateString(Date())}")
175
+
172
176
  FWEventUtils.sendCustomCTAClickEvent(reactApplicationContext, actionUrl)
177
+
178
+ if (!appComponentName.isNullOrBlank() && !customCTALinkContentPageRouteName.isNullOrBlank()) {
179
+ val activity = FWInitializationProvider.INSTANCE.resumedActivity
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
188
+ }
189
+
173
190
  return FWVideoPlayerUtils.customCTAClickEnabled
174
191
  }
175
192
  }
@@ -228,6 +245,18 @@ class FireworkSDKModule(
228
245
  })
229
246
  }
230
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
+
231
260
  @ReactMethod
232
261
  fun addListener(eventName: String?, promise: Promise) {
233
262
  // Set up any upstream listeners or background tasks as necessary
@@ -246,4 +275,9 @@ class FireworkSDKModule(
246
275
  return "FireworkSDK"
247
276
  }
248
277
 
278
+ companion object {
279
+ var appComponentName: String? = null
280
+ var customCTALinkContentPageRouteName: String? = null
281
+ }
282
+
249
283
  }
@@ -0,0 +1,66 @@
1
+ package com.fireworksdk.bridge.reactnative.pages
2
+
3
+ import android.app.Activity
4
+ import android.content.Intent
5
+ import android.os.Bundle
6
+ import androidx.appcompat.app.AppCompatActivity
7
+ import androidx.fragment.app.Fragment
8
+ import com.facebook.react.ReactFragment
9
+ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
10
+ import com.fireworksdk.bridge.R
11
+ import com.fireworksdk.bridge.utils.FWBundleUtils
12
+
13
+
14
+ class FWContainerActivity : AppCompatActivity(), DefaultHardwareBackBtnHandler {
15
+
16
+ override fun onCreate(savedInstanceState: Bundle?) {
17
+ super.onCreate(savedInstanceState)
18
+ setContentView(R.layout.fw_bridge_fragment_container)
19
+
20
+ val componentName = intent.getStringExtra(KEY_COMPONENT_NAME)
21
+ val params = intent.getSerializableExtra(KEY_PARAMS) as HashMap<String, Any?>?
22
+
23
+ val reactNativeFragment: Fragment = ReactFragment.Builder()
24
+ .setComponentName(componentName)
25
+ .setLaunchOptions(FWBundleUtils.mapToBundle(params))
26
+ .build()
27
+
28
+ supportFragmentManager
29
+ .beginTransaction()
30
+ .add(R.id.fw_bridge_container, reactNativeFragment)
31
+ .commit()
32
+ }
33
+
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
+ // }
45
+ }
46
+ }
47
+
48
+ companion object {
49
+
50
+ private const val KEY_PARAMS = "params"
51
+ private const val KEY_COMPONENT_NAME = "componentName"
52
+
53
+ fun createIntent(activity: Activity, componentName: String?, params: HashMap<String, Any?>?): Intent {
54
+ val intent = Intent(activity, FWContainerActivity::class.java)
55
+ intent.putExtra(KEY_COMPONENT_NAME, componentName)
56
+ intent.putExtra(KEY_PARAMS, params)
57
+ intent.flags = Intent.FLAG_ACTIVITY_NO_ANIMATION
58
+ activity.overridePendingTransition(0, 0)
59
+ return intent
60
+ }
61
+ }
62
+
63
+ override fun invokeDefaultOnBackPressed() {
64
+ super.onBackPressed();
65
+ }
66
+ }