react-native-firework-sdk 1.2.0-beta.1 → 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.
- package/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +0 -4
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +19 -6
- package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModel.kt +2 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModel.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedSource.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +6 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt +2 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +2 -2
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt +3 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +3 -14
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +4 -19
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +41 -4
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWContainerActivity.kt +22 -10
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWDataUtils.kt +119 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +50 -3
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWBundleUtils.kt +86 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWDateUtils.kt +15 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +12 -2
- package/ios/Components/VideoFeed.swift +6 -25
- package/ios/Components/VideoFeedManager.m +1 -0
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +0 -4
- package/ios/Models/NativeToRN/FireworkEventName.swift +1 -0
- package/ios/Models/RNToNative/RCTConvert+FireworkSDKModule.swift +0 -20
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +2 -1
- package/ios/Modules/FWNavigatorModule/FWNavigatorContainerViewController.swift +4 -12
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.m +2 -2
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +41 -11
- package/ios/Modules/FWNavigatorModule/FWNavigatorProtocol.swift +2 -2
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +24 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +3 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +51 -31
- package/ios/Modules/Shopping/CartViewController.swift +6 -1
- package/ios/Modules/Shopping/ShoppingModule.m +1 -2
- package/ios/Modules/Shopping/ShoppingModule.swift +10 -12
- package/lib/commonjs/FWNavigator.js +21 -15
- package/lib/commonjs/FWNavigator.js.map +1 -1
- package/lib/commonjs/FireworkSDK.js +49 -5
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/LiveStream.js +2 -2
- package/lib/commonjs/LiveStream.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +4 -18
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/FWVideoFeed.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +33 -1
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/constants/FWErrorMessage.js.map +1 -1
- package/lib/commonjs/index.js +0 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +3 -2
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/NewNativeContainerProps.js +2 -0
- package/lib/commonjs/models/{AdConfig.js.map → NewNativeContainerProps.js.map} +0 -0
- package/lib/commonjs/models/VideoFeedSource.js +0 -4
- package/lib/commonjs/modules/FWNavigatorModule.js.map +1 -1
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/LiveStreamModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/commonjs/utils/FWLoggerUtil.js +45 -0
- package/lib/commonjs/utils/FWLoggerUtil.js.map +1 -0
- package/lib/module/FWNavigator.js +15 -16
- package/lib/module/FWNavigator.js.map +1 -1
- package/lib/module/FireworkSDK.js +45 -5
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/LiveStream.js +4 -4
- package/lib/module/LiveStream.js.map +1 -1
- package/lib/module/VideoShopping.js +4 -18
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/FWVideoFeed.js +1 -1
- package/lib/module/components/FWVideoFeed.js.map +1 -1
- package/lib/module/components/VideoFeed.js +33 -1
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/constants/FWErrorMessage.js.map +1 -1
- package/lib/module/index.js +0 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +3 -2
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/NewNativeContainerProps.js +2 -0
- package/lib/module/models/{AdConfig.js.map → NewNativeContainerProps.js.map} +0 -0
- package/lib/module/models/VideoFeedSource.js +1 -1
- package/lib/module/modules/FWNavigatorModule.js.map +1 -1
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/LiveStreamModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/module/utils/FWLoggerUtil.js +36 -0
- package/lib/module/utils/FWLoggerUtil.js.map +1 -0
- package/lib/typescript/FWNavigator.d.ts +9 -7
- package/lib/typescript/FireworkSDK.d.ts +16 -4
- package/lib/typescript/LiveStream.d.ts +1 -1
- package/lib/typescript/VideoShopping.d.ts +2 -9
- package/lib/typescript/components/VideoFeed.d.ts +8 -1
- package/lib/typescript/constants/FWErrorMessage.d.ts +1 -1
- package/lib/typescript/index.d.ts +4 -4
- package/lib/typescript/models/FWEventName.d.ts +4 -3
- package/lib/typescript/models/FeedItemDetails.d.ts +1 -1
- package/lib/typescript/models/NewNativeContainerProps.d.ts +6 -0
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +4 -0
- package/lib/typescript/models/VideoFeedSource.d.ts +1 -2
- package/lib/typescript/modules/FWNavigatorModule.d.ts +3 -1
- package/lib/typescript/modules/FireworkSDKModule.d.ts +5 -4
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -2
- package/lib/typescript/utils/FWLoggerUtil.d.ts +6 -0
- package/package.json +3 -1
- package/react-native-firework-sdk.podspec +1 -1
- package/src/FWNavigator.tsx +22 -12
- package/src/FireworkSDK.ts +46 -7
- package/src/LiveStream.ts +9 -7
- package/src/VideoShopping.ts +10 -21
- package/src/components/FWVideoFeed.tsx +5 -5
- package/src/components/VideoFeed.tsx +48 -14
- package/src/constants/FWErrorMessage.ts +1 -3
- package/src/index.tsx +5 -13
- package/src/models/AdBadgeConfiguration.ts +1 -1
- package/src/models/FWError.ts +1 -1
- package/src/models/FWEventName.ts +3 -2
- package/src/models/FWEvents.ts +1 -1
- package/src/models/FeedItemDetails.ts +2 -2
- package/src/models/LiveStreamEventDetails.ts +1 -1
- package/src/models/LiveStreamMessageDetails.ts +1 -1
- package/src/models/NewNativeContainerProps.ts +4 -0
- package/src/models/VideoFeedConfiguration.ts +6 -2
- package/src/models/VideoFeedSource.ts +6 -2
- package/src/models/VideoPlayerConfiguration.ts +2 -2
- package/src/modules/FWNavigatorModule.ts +1 -1
- package/src/modules/FireworkSDKModule.ts +5 -6
- package/src/modules/LiveStreamModule.ts +1 -5
- package/src/modules/ShoppingModule.ts +5 -2
- package/src/utils/FWLoggerUtil.ts +40 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWVideoShoppingCartActivity.kt +0 -43
- package/ios/Modules/FireworkSDKModule/MobileADConfiguration.swift +0 -17
- package/lib/commonjs/components/CartContainer.js +0 -35
- package/lib/commonjs/components/CartContainer.js.map +0 -1
- package/lib/commonjs/components/NavigationContainer.js +0 -36
- package/lib/commonjs/components/NavigationContainer.js.map +0 -1
- package/lib/commonjs/models/AdConfig.js +0 -2
- package/lib/module/components/CartContainer.js +0 -18
- package/lib/module/components/CartContainer.js.map +0 -1
- package/lib/module/components/NavigationContainer.js +0 -21
- package/lib/module/components/NavigationContainer.js.map +0 -1
- package/lib/module/models/AdConfig.js +0 -2
- package/lib/typescript/components/CartContainer.d.ts +0 -3
- package/lib/typescript/components/NavigationContainer.d.ts +0 -6
- package/lib/typescript/models/AdConfig.d.ts +0 -10
- package/src/components/CartContainer.tsx +0 -20
- package/src/components/NavigationContainer.tsx +0 -22
- package/src/models/AdConfig.ts +0 -10
package/android/build.gradle
CHANGED
|
@@ -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.
|
|
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,
|
|
@@ -7,10 +7,6 @@
|
|
|
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"
|
|
@@ -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.
|
|
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
|
}
|
|
@@ -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
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt
CHANGED
|
@@ -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()
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt
CHANGED
|
@@ -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(
|
|
8
|
+
fun pushNativeContainer(props: ReadableMap?, promise: Promise)
|
|
8
9
|
fun popNativeContainer(promise: Promise)
|
|
9
10
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt
CHANGED
|
@@ -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
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FireworkSDKInterface.kt
CHANGED
|
@@ -5,10 +5,12 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
5
5
|
|
|
6
6
|
interface FireworkSDKInterface {
|
|
7
7
|
|
|
8
|
-
fun init(userId: String
|
|
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
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt
CHANGED
|
@@ -3,7 +3,7 @@ package com.fireworksdk.bridge.reactnative.module
|
|
|
3
3
|
import com.facebook.react.bridge.*
|
|
4
4
|
import com.fireworksdk.bridge.reactnative.FWInitializationProvider
|
|
5
5
|
import com.fireworksdk.bridge.reactnative.models.FWNavigatorInterface
|
|
6
|
-
import com.fireworksdk.bridge.reactnative.
|
|
6
|
+
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
7
7
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
8
8
|
|
|
9
9
|
|
|
@@ -12,19 +12,8 @@ class FWNavigatorModule(
|
|
|
12
12
|
) : ReactContextBaseJavaModule(reactContext), FWNavigatorInterface {
|
|
13
13
|
|
|
14
14
|
@ReactMethod
|
|
15
|
-
override fun pushNativeContainer(
|
|
16
|
-
|
|
17
|
-
val activity = FWInitializationProvider.INSTANCE.resumedActivity
|
|
18
|
-
|
|
19
|
-
if (activity == null) {
|
|
20
|
-
promise.resolve(false)
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
UiThreadUtil.runOnUiThread {
|
|
25
|
-
activity.startActivity(FWContainerActivity.createIntent(activity, callbackId))
|
|
26
|
-
}
|
|
27
|
-
promise.resolve(true)
|
|
15
|
+
override fun pushNativeContainer(props: ReadableMap?, promise: Promise) {
|
|
16
|
+
FWEventUtils.pushNativeContainer(reactApplicationContext, props, promise)
|
|
28
17
|
}
|
|
29
18
|
|
|
30
19
|
@ReactMethod
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt
CHANGED
|
@@ -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
|
-
|
|
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
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt
CHANGED
|
@@ -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
|
|
39
|
-
|
|
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
|
|
113
|
+
private fun initSdk(userId: String?) {
|
|
110
114
|
val clientId = getAppid()
|
|
111
115
|
if (clientId.isNullOrBlank()) {
|
|
112
116
|
val errorMsg = "The appid is invalid"
|
|
@@ -166,7 +170,23 @@ class FireworkSDKModule(
|
|
|
166
170
|
FwSDK.ctaClickHandler = object: FwSDK.CtaClickHandler {
|
|
167
171
|
override fun ctaClicked(label: String, actionUrl: String?): Boolean {
|
|
168
172
|
FWLogUtils.d { "ctaClicked" }
|
|
173
|
+
|
|
174
|
+
FWEventUtils.sendLogMessageEvent(reactApplicationContext, "[Android] Receive CustomCTAClick event ${FWDateUtils.getDateString(Date())}")
|
|
175
|
+
|
|
169
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
|
+
|
|
170
190
|
return FWVideoPlayerUtils.customCTAClickEnabled
|
|
171
191
|
}
|
|
172
192
|
}
|
|
@@ -225,6 +245,18 @@ class FireworkSDKModule(
|
|
|
225
245
|
})
|
|
226
246
|
}
|
|
227
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
|
+
|
|
228
260
|
@ReactMethod
|
|
229
261
|
fun addListener(eventName: String?, promise: Promise) {
|
|
230
262
|
// Set up any upstream listeners or background tasks as necessary
|
|
@@ -243,4 +275,9 @@ class FireworkSDKModule(
|
|
|
243
275
|
return "FireworkSDK"
|
|
244
276
|
}
|
|
245
277
|
|
|
278
|
+
companion object {
|
|
279
|
+
var appComponentName: String? = null
|
|
280
|
+
var customCTALinkContentPageRouteName: String? = null
|
|
281
|
+
}
|
|
282
|
+
|
|
246
283
|
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWContainerActivity.kt
CHANGED
|
@@ -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
|
|
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(
|
|
22
|
-
.setLaunchOptions(
|
|
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
|
-
|
|
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
|
+
// }
|
|
34
45
|
}
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
companion object {
|
|
38
49
|
|
|
39
|
-
private const val
|
|
40
|
-
private const val
|
|
50
|
+
private const val KEY_PARAMS = "params"
|
|
51
|
+
private const val KEY_COMPONENT_NAME = "componentName"
|
|
41
52
|
|
|
42
|
-
fun createIntent(activity: Activity,
|
|
53
|
+
fun createIntent(activity: Activity, componentName: String?, params: HashMap<String, Any?>?): Intent {
|
|
43
54
|
val intent = Intent(activity, FWContainerActivity::class.java)
|
|
44
|
-
intent.putExtra(
|
|
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,15 +1,52 @@
|
|
|
1
1
|
package com.fireworksdk.bridge.reactnative.utils
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import com.facebook.react.bridge
|
|
5
|
-
import com.facebook.react.bridge.WritableMap
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.facebook.react.bridge.*
|
|
6
5
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
7
6
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
8
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
|
|
12
|
+
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
9
13
|
import com.loopnow.fireworklibrary.data.Product
|
|
14
|
+
import java.util.*
|
|
10
15
|
|
|
11
16
|
object FWEventUtils {
|
|
12
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
|
+
|
|
13
50
|
fun sendInitSuccessEvent(reactContext: ReactContext) {
|
|
14
51
|
sendEvent(reactContext, FWEventName.SDKIni.rawValue, Arguments.createMap())
|
|
15
52
|
}
|
|
@@ -109,6 +146,16 @@ object FWEventUtils {
|
|
|
109
146
|
.emit(eventName, params)
|
|
110
147
|
}
|
|
111
148
|
|
|
149
|
+
fun sendLogMessageEvent(reactContext: ReactContext, message: String?) {
|
|
150
|
+
FWLogUtils.d { message }
|
|
151
|
+
|
|
152
|
+
if (Log.DEBUG >= FWLogUtils.logLevel) {
|
|
153
|
+
val eventMap = Arguments.createMap()
|
|
154
|
+
eventMap.putString("message", message)
|
|
155
|
+
sendEvent(reactContext, FWEventName.LogMessage.rawValue, eventMap)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
112
159
|
fun receiveVideoFeedLoadFinishedSuccessEvent(reactContext: ReactContext, targetTag: Int) {
|
|
113
160
|
receiveEvent(reactContext, targetTag, FWFeedViewEventName.VideoFeedLoadFinished.rawValue, null)
|
|
114
161
|
}
|