react-native-firework-sdk 1.3.0-beta.3 → 1.3.1-beta.1
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 +2 -2
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/fireworksdk/bridge/{reactnative/FWInitializationProvider.kt → FWInitializationProvider.kt} +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModel.kt +3 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModel.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoShoppingProduct.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +5 -2
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +69 -30
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +10 -5
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +18 -0
- package/ios/Components/VideoFeed.swift +95 -35
- package/ios/Components/VideoFeedConfiguration.swift +15 -3
- package/ios/Components/VideoFeedManager.m +1 -0
- package/ios/Components/VideoPlayerConfiguration.swift +3 -2
- package/ios/Models/NativeToRN/FireworkEventName.swift +1 -0
- package/ios/Models/RNToNative/RCTConvert+FireworkSDKModule.swift +24 -4
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +1 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +5 -0
- package/ios/Modules/Shopping/CartViewController.swift +23 -40
- package/ios/Modules/Shopping/Product.swift +1 -0
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +1 -6
- package/ios/Modules/Shopping/ShoppingModule.m +6 -4
- package/ios/Modules/Shopping/ShoppingModule.swift +89 -31
- package/lib/commonjs/FireworkSDK.js +14 -3
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +77 -16
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +28 -3
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FireworkSDK.js +14 -3
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +70 -16
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/VideoFeed.js +28 -3
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FireworkSDK.d.ts +5 -0
- package/lib/typescript/VideoShopping.d.ts +15 -1
- package/lib/typescript/components/VideoFeed.d.ts +1 -0
- package/lib/typescript/index.d.ts +4 -4
- package/lib/typescript/models/ProductUnit.d.ts +12 -0
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +33 -5
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +5 -1
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -0
- package/package.json +2 -6
- package/react-native-firework-sdk.podspec +1 -1
- package/src/FireworkSDK.ts +15 -3
- package/src/VideoShopping.ts +94 -15
- package/src/components/VideoFeed.tsx +22 -1
- package/src/index.tsx +6 -1
- package/src/models/ProductUnit.ts +13 -0
- package/src/models/VideoFeedConfiguration.ts +34 -5
- package/src/models/VideoPlayerConfiguration.ts +5 -1
- package/src/modules/ShoppingModule.ts +2 -0
|
@@ -16,14 +16,34 @@ extension RCTConvert {
|
|
|
16
16
|
if let style = videoPlayerStyle(config["playerStyle"] as? String) {
|
|
17
17
|
finalConfig.playerStyle = style
|
|
18
18
|
}
|
|
19
|
+
|
|
19
20
|
if let action = videoCompleteAction(config["videoCompleteAction"] as? String) {
|
|
20
21
|
finalConfig.videoCompleteAction = action
|
|
21
22
|
}
|
|
23
|
+
|
|
22
24
|
if let showShareButton = config["showShareButton"] as? Bool {
|
|
23
|
-
finalConfig.shareButton.isHidden = showShareButton
|
|
25
|
+
finalConfig.shareButton.isHidden = !showShareButton
|
|
24
26
|
}
|
|
27
|
+
|
|
25
28
|
if let ctaStyle = ctaButtonStyle(config["ctaButtonStyle"] as? Dictionary) {
|
|
26
|
-
finalConfig.ctaButton = ctaStyle
|
|
29
|
+
finalConfig.ctaButton.contentConfiguration = ctaStyle
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if let showPlaybackButton = config["showPlaybackButton"] as? Bool {
|
|
33
|
+
finalConfig.playbackButton.isHidden = !showPlaybackButton
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if let showMuteButton = config["showMuteButton"] as? Bool {
|
|
37
|
+
finalConfig.muteButton.isHidden = !showMuteButton
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if let launchBehaviorString = config["launchBehavior"] as? String,
|
|
41
|
+
let launchBehavior = VideoPlayerConfiguration.VideoLaunchBehavior(rawValue: launchBehaviorString) {
|
|
42
|
+
finalConfig.onFirstLaunch = launchBehavior.behavior()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if let showBranding = config["showBranding"] as? Bool {
|
|
46
|
+
finalConfig.videoDetail.fireworkAttribution.isHidden = !showBranding
|
|
27
47
|
}
|
|
28
48
|
|
|
29
49
|
return finalConfig
|
|
@@ -62,8 +82,8 @@ extension RCTConvert {
|
|
|
62
82
|
if let textColor = rStyle["textColor"] as? String {
|
|
63
83
|
btnContentConfig.textColor = textColor.uicolor()
|
|
64
84
|
}
|
|
65
|
-
if let fontSize = rStyle["fontSize"] as?
|
|
66
|
-
btnContentConfig.font = UIFont.systemFont(ofSize:
|
|
85
|
+
if let fontSize = rStyle["fontSize"] as? Double {
|
|
86
|
+
btnContentConfig.font = UIFont.systemFont(ofSize: fontSize)
|
|
67
87
|
}
|
|
68
88
|
|
|
69
89
|
return btnContentConfig
|
|
@@ -69,6 +69,11 @@ extension FireworkSDKModule: FireworkVideoPlaybackDelegate {
|
|
|
69
69
|
|
|
70
70
|
extension FireworkSDKModule: FireworkVideoFeedDelegate {
|
|
71
71
|
func fireworkVideoDidTapThumbnail(_ eventDetails: FeedEventDetails) {
|
|
72
|
+
#if DEBUG
|
|
73
|
+
let formatter = DateFormatter()
|
|
74
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
75
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": "[iOS] Send VideoFeedClick event id: \(eventDetails.id) \(formatter.string(from: Date()))"])
|
|
76
|
+
#endif
|
|
72
77
|
sendEvent(withName: FWEventName.VideoFeedClick.rawValue, body: ["info": eventDetails.jsObject])
|
|
73
78
|
}
|
|
74
79
|
}
|
|
@@ -9,17 +9,18 @@ import UIKit
|
|
|
9
9
|
import FireworkVideo
|
|
10
10
|
|
|
11
11
|
class CartViewController: UIViewController, CartViewRepresentable {
|
|
12
|
-
var properties: [String: Any] = [:]
|
|
13
|
-
var indicator: UIActivityIndicatorView? = nil
|
|
14
12
|
var callbackId: Int!
|
|
15
|
-
var
|
|
13
|
+
var enableShowCustomCartView: Bool = true
|
|
14
|
+
private var properties: [String: Any] = [:]
|
|
15
|
+
private var directShowCartPage = false
|
|
16
16
|
|
|
17
|
-
init(callbackId: Int) {
|
|
17
|
+
init(callbackId: Int, enableShowCustomCartView: Bool) {
|
|
18
18
|
self.callbackId = callbackId
|
|
19
|
-
|
|
19
|
+
self.enableShowCustomCartView = enableShowCustomCartView
|
|
20
20
|
super.init(nibName: nil, bundle: nil)
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
if enableShowCustomCartView {
|
|
22
|
+
NotificationCenter.default.addObserver(self, selector: #selector(showCustomCartView), name: Notification.Name(rawValue: "showCustomCartView"), object: nil)
|
|
23
|
+
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
required init?(coder: NSCoder) {
|
|
@@ -28,29 +29,28 @@ class CartViewController: UIViewController, CartViewRepresentable {
|
|
|
28
29
|
|
|
29
30
|
override func viewWillAppear(_ animated: Bool) {
|
|
30
31
|
super.viewWillAppear(animated)
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
if enableShowCustomCartView {
|
|
33
|
+
self.navigationController?.setNavigationBarHidden(true, animated: true)
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
override func viewDidLoad() {
|
|
36
38
|
super.viewDidLoad()
|
|
37
39
|
|
|
38
|
-
if directShowCartPage {
|
|
40
|
+
if directShowCartPage && enableShowCustomCartView {
|
|
39
41
|
directShowCustomCartView()
|
|
40
|
-
} else {
|
|
41
|
-
setupIndicatorView()
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
override func viewWillDisappear(_ animated: Bool) {
|
|
46
46
|
super.viewWillDisappear(animated)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
if enableShowCustomCartView {
|
|
48
|
+
self.navigationController?.setNavigationBarHidden(false, animated: true)
|
|
49
|
+
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
@objc func showCustomCartView(_ noti: NSNotification) {
|
|
53
|
-
guard let cbId = noti.userInfo?["
|
|
53
|
+
guard let cbId = noti.userInfo?["cbId"] as? Int, callbackId == cbId else {
|
|
54
54
|
return
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -65,31 +65,14 @@ class CartViewController: UIViewController, CartViewRepresentable {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
private func setupIndicatorView() {
|
|
69
|
-
let indicator = UIActivityIndicatorView(frame: .zero)
|
|
70
|
-
if #available(iOS 13.0, *) {
|
|
71
|
-
indicator.style = .large
|
|
72
|
-
} else {
|
|
73
|
-
indicator.style = .whiteLarge
|
|
74
|
-
}
|
|
75
|
-
indicator.color = UIColor.white
|
|
76
|
-
view.addSubview(indicator)
|
|
77
|
-
indicator.translatesAutoresizingMaskIntoConstraints = false
|
|
78
|
-
|
|
79
|
-
NSLayoutConstraint.activate([
|
|
80
|
-
indicator.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
|
81
|
-
indicator.centerYAnchor.constraint(equalTo: view.centerYAnchor)
|
|
82
|
-
])
|
|
83
|
-
|
|
84
|
-
indicator.startAnimating()
|
|
85
|
-
|
|
86
|
-
self.indicator = indicator
|
|
87
|
-
}
|
|
88
|
-
|
|
89
68
|
private func directShowCustomCartView() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
69
|
+
guard let appComponentName = gAppComponentName else {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
let rctRootView = RCTRootView.init(
|
|
73
|
+
bridge: RCTBridge.current(),
|
|
74
|
+
moduleName: appComponentName,
|
|
75
|
+
initialProperties: properties)
|
|
93
76
|
view.addSubview(rctRootView)
|
|
94
77
|
rctRootView.translatesAutoresizingMaskIntoConstraints = false
|
|
95
78
|
|
|
@@ -8,17 +8,12 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
|
|
10
10
|
struct ProductInfoViewConfiguration: Codable {
|
|
11
|
-
var cartIcon: CartIconConfiguration?
|
|
12
11
|
var addToCartButton: ButtonConfiguration?
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
struct CartIconConfiguration: Codable {
|
|
16
|
-
var isHidden: Bool? = false
|
|
17
|
-
}
|
|
18
13
|
struct ButtonConfiguration: Codable {
|
|
19
14
|
var backgroundColor: String?
|
|
20
15
|
var textColor: String?
|
|
21
|
-
var fontSize:
|
|
16
|
+
var fontSize: Double?
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
}
|
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
_RCT_EXTERN_REMAP_METHOD(init, initialize, NO)
|
|
13
13
|
RCT_EXTERN_METHOD(setCartIconVisible:(BOOL)visible)
|
|
14
14
|
RCT_EXTERN_METHOD(setCartItemCount:(int)itemCounts)
|
|
15
|
-
RCT_EXTERN_METHOD(updateVideoProducts:(NSArray *)products cbId:(nonnull NSNumber *)
|
|
16
|
-
RCT_EXTERN_METHOD(updateProductViewConfig:(NSDictionary *)config cbId:(nonnull NSNumber *)
|
|
17
|
-
RCT_EXTERN_METHOD(updateAddToCartStatus:(NSString *)res tips:(nullable NSString *)tips cbId:(nonnull NSNumber *)
|
|
18
|
-
RCT_EXTERN_METHOD(jumpToCartPage:(nonnull NSNumber *)
|
|
15
|
+
RCT_EXTERN_METHOD(updateVideoProducts:(NSArray *)products cbId:(nonnull NSNumber *)cbId)
|
|
16
|
+
RCT_EXTERN_METHOD(updateProductViewConfig:(NSDictionary *)config cbId:(nonnull NSNumber *)cbId)
|
|
17
|
+
RCT_EXTERN_METHOD(updateAddToCartStatus:(NSString *)res tips:(nullable NSString *)tips cbId:(nonnull NSNumber *)cbId)
|
|
18
|
+
RCT_EXTERN_METHOD(jumpToCartPage:(nonnull NSNumber *)cbId props:(NSDictionary *)props)
|
|
19
|
+
RCT_EXTERN_METHOD(setCustomClickCartIconEnabled:(BOOL)enabled resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
20
|
+
RCT_EXTERN_METHOD(clearCallbackId:(nonnull NSNumber *)cbId eventName:(nonnull NSString *)name)
|
|
19
21
|
|
|
20
22
|
@end
|
|
@@ -8,17 +8,19 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
import FireworkVideo
|
|
10
10
|
|
|
11
|
-
var gCartViewController: CartViewController?;
|
|
11
|
+
weak var gCartViewController: CartViewController?;
|
|
12
12
|
|
|
13
13
|
@objc(ShoppingModule)
|
|
14
14
|
class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewControllerProviding {
|
|
15
15
|
|
|
16
16
|
private var productInfoViewConfigurator: (Int, ProductInfoViewConfigurable)?
|
|
17
|
-
private var
|
|
18
|
-
private var
|
|
17
|
+
private var addToCartHandlerMap: Dictionary<Int, AddToCartHandler> = [:]
|
|
18
|
+
private var productHydratingMap: Dictionary<Int, ProductHydrating> = [:]
|
|
19
|
+
|
|
19
20
|
private var cartViewController: CartViewController?
|
|
20
21
|
private var cartIconVisible = true
|
|
21
22
|
private var itemCounts = 0
|
|
23
|
+
private var customClickCartIconEnabled = false
|
|
22
24
|
|
|
23
25
|
override func supportedEvents() -> [String]! {
|
|
24
26
|
ShoppingEventName.allCases.map { $0.rawValue }
|
|
@@ -66,15 +68,42 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
66
68
|
|
|
67
69
|
@objc
|
|
68
70
|
func updateVideoProducts(_ products: [AnyObject]?, cbId: NSNumber) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
#if DEBUG
|
|
72
|
+
let formatter = DateFormatter()
|
|
73
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
74
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: [
|
|
75
|
+
"message": "[iOS] Call updateVideoProducts 1 \(formatter.string(from: Date()))"
|
|
76
|
+
])
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
guard let productHydrating = productHydratingMap[Int(truncating: cbId)] else {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
productHydratingMap.removeValue(forKey: Int(truncating: cbId))
|
|
84
|
+
|
|
85
|
+
#if DEBUG
|
|
86
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: [
|
|
87
|
+
"message": "[iOS] Call updateVideoProducts 2 \(formatter.string(from: Date()))"
|
|
88
|
+
])
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
guard let rProducts = RCTConvert.buildProducts(products) else {
|
|
72
92
|
return
|
|
73
93
|
}
|
|
94
|
+
|
|
95
|
+
#if DEBUG
|
|
96
|
+
let productIds = rProducts.map({ product in
|
|
97
|
+
return product.productId
|
|
98
|
+
}).joined(separator: ",")
|
|
99
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: [
|
|
100
|
+
"message": "[iOS] Call updateVideoProducts 3 productIds: \(productIds) \(formatter.string(from: Date()))"
|
|
101
|
+
])
|
|
102
|
+
#endif
|
|
74
103
|
|
|
75
104
|
DispatchQueue.main.async {
|
|
76
105
|
for product in rProducts {
|
|
77
|
-
productHydrating.
|
|
106
|
+
productHydrating.hydrateProduct(product.productId, { build in
|
|
78
107
|
return ShoppingModule.hydrateProduct(product, build)
|
|
79
108
|
})
|
|
80
109
|
}
|
|
@@ -99,16 +128,17 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
99
128
|
|
|
100
129
|
@objc
|
|
101
130
|
func updateAddToCartStatus(_ res: String, tips: String?, cbId: NSNumber) {
|
|
102
|
-
guard let handler =
|
|
131
|
+
guard let handler = addToCartHandlerMap[Int(truncating: cbId)] else {
|
|
103
132
|
return
|
|
104
133
|
}
|
|
105
|
-
|
|
134
|
+
|
|
135
|
+
addToCartHandlerMap.removeValue(forKey: Int(truncating: cbId))
|
|
136
|
+
|
|
106
137
|
DispatchQueue.main.async {
|
|
107
|
-
// config.indicator.isHidden = itemCounts == 0
|
|
108
138
|
if res == "success" {
|
|
109
|
-
handler
|
|
139
|
+
handler(.feedbackOnly(.success(message: tips ?? "success")))
|
|
110
140
|
} else {
|
|
111
|
-
handler
|
|
141
|
+
handler(.feedbackOnly(.failure(message: tips ?? "failure")))
|
|
112
142
|
}
|
|
113
143
|
}
|
|
114
144
|
}
|
|
@@ -118,12 +148,27 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
118
148
|
DispatchQueue.main.async {
|
|
119
149
|
let properties: [String: Any] = (props as? [String: Any]) ?? [:]
|
|
120
150
|
let noti = Notification(name: Notification.Name(rawValue: "showCustomCartView"), object: nil, userInfo: [
|
|
121
|
-
"
|
|
151
|
+
"cbId": Int(truncating: cbId),
|
|
122
152
|
"properties": properties
|
|
123
153
|
])
|
|
124
154
|
NotificationCenter.default.post(noti)
|
|
125
155
|
}
|
|
126
156
|
}
|
|
157
|
+
|
|
158
|
+
@objc
|
|
159
|
+
func setCustomClickCartIconEnabled(_ enabled: Bool, resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) {
|
|
160
|
+
customClickCartIconEnabled = enabled
|
|
161
|
+
resolver([:])
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@objc
|
|
165
|
+
func clearCallbackId(_ cbId: NSNumber, eventName: String) {
|
|
166
|
+
if eventName == ShoppingEventName.UpdateProductDetails.rawValue {
|
|
167
|
+
productHydratingMap.removeValue(forKey: Int(truncating: cbId))
|
|
168
|
+
} else if eventName == ShoppingEventName.AddToCart.rawValue {
|
|
169
|
+
addToCartHandlerMap.removeValue(forKey: Int(truncating: cbId))
|
|
170
|
+
}
|
|
171
|
+
}
|
|
127
172
|
|
|
128
173
|
// MARK: - FireworkVideoShoppingDelegate
|
|
129
174
|
func fireworkShopping(_ fireworkShopping: FireworkVideoShopping, willDisplayProductInfo productInfoViewConfigurator: ProductInfoViewConfigurable, forVideo video: VideoDetails) {
|
|
@@ -135,15 +180,23 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
135
180
|
|
|
136
181
|
func fireworkShopping(_ fireworkShopping: FireworkVideoShopping, updateDetailsForProducts products: [ProductID], forVideo video: VideoDetails, _ productHydrator: ProductHydrating) {
|
|
137
182
|
let callbackId = ShoppingModule.generateCallbackId()
|
|
138
|
-
self.
|
|
183
|
+
self.productHydratingMap[callbackId] = productHydrator
|
|
184
|
+
|
|
185
|
+
#if DEBUG
|
|
186
|
+
let formatter = DateFormatter()
|
|
187
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
188
|
+
sendEvent(
|
|
189
|
+
withName: FWEventName.LogMessage.rawValue,
|
|
190
|
+
body: ["message": "[iOS] Send UpdateProductDetails event productIds: \(products) and videoId: \(video.videoID) \(formatter.string(from: Date()))"])
|
|
191
|
+
#endif
|
|
139
192
|
|
|
140
193
|
sendEvent(withName: ShoppingEventName.UpdateProductDetails.rawValue, body: ["productIds": products, "callbackId": callbackId])
|
|
141
194
|
}
|
|
142
195
|
|
|
143
196
|
func fireworkShopping(_ fireworkShopping: FireworkVideoShopping, addProductVariantToCart item: SelectedProductVariant, fromVideo video: VideoDetails, _ addToCartCompletionHandler: @escaping AddToCartHandler) {
|
|
144
197
|
let callbackId = ShoppingModule.generateCallbackId()
|
|
145
|
-
self.
|
|
146
|
-
|
|
198
|
+
self.addToCartHandlerMap[callbackId] = addToCartCompletionHandler
|
|
199
|
+
|
|
147
200
|
sendEvent(withName: ShoppingEventName.AddToCart.rawValue, body: ["productId": item.productID, "unitId": item.unitID, "callbackId": callbackId])
|
|
148
201
|
}
|
|
149
202
|
|
|
@@ -152,31 +205,33 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
152
205
|
let callbackId = ShoppingModule.generateCallbackId()
|
|
153
206
|
sendEvent(withName: ShoppingEventName.ClickCartIcon.rawValue, body: ["callbackId": callbackId])
|
|
154
207
|
|
|
155
|
-
|
|
156
|
-
|
|
208
|
+
let cartVC = CartViewController(
|
|
209
|
+
callbackId: callbackId,
|
|
210
|
+
enableShowCustomCartView: !customClickCartIconEnabled)
|
|
211
|
+
if !customClickCartIconEnabled {
|
|
212
|
+
gCartViewController = cartVC
|
|
213
|
+
} else {
|
|
214
|
+
gCartViewController = nil
|
|
215
|
+
}
|
|
216
|
+
return cartVC
|
|
157
217
|
}
|
|
158
218
|
}
|
|
159
219
|
|
|
160
220
|
private extension ShoppingModule {
|
|
161
221
|
|
|
162
222
|
static func hydrateProductViewConfig(_ config: ProductInfoViewConfiguration, _ productInfoViewConfigurator: ProductInfoViewConfigurable) {
|
|
163
|
-
if let cartIcon = config.cartIcon {
|
|
164
|
-
if let hidden = cartIcon.isHidden {
|
|
165
|
-
var config = productInfoViewConfigurator.shoppingCartIconConfiguration
|
|
166
|
-
config.isHidden = hidden
|
|
167
|
-
productInfoViewConfigurator.shoppingCartIconConfiguration = config
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
223
|
if let buttonConfiguration = config.addToCartButton {
|
|
171
224
|
var config = productInfoViewConfigurator.productDetailsConfiguration
|
|
172
|
-
if let backgroundColor = buttonConfiguration.backgroundColor
|
|
225
|
+
if let backgroundColor = buttonConfiguration.backgroundColor,
|
|
226
|
+
backgroundColor.count > 0 {
|
|
173
227
|
config.addToCartButton.backgroundColor = backgroundColor.uicolor()
|
|
174
228
|
}
|
|
175
|
-
if let textColor = buttonConfiguration.textColor
|
|
229
|
+
if let textColor = buttonConfiguration.textColor,
|
|
230
|
+
textColor.count > 0 {
|
|
176
231
|
config.addToCartButton.textColor = textColor.uicolor()
|
|
177
232
|
}
|
|
178
233
|
if let fontSize = buttonConfiguration.fontSize {
|
|
179
|
-
config.addToCartButton.font = UIFont.systemFont(ofSize:
|
|
234
|
+
config.addToCartButton.font = UIFont.systemFont(ofSize: fontSize)
|
|
180
235
|
}
|
|
181
236
|
productInfoViewConfigurator.productDetailsConfiguration = config
|
|
182
237
|
}
|
|
@@ -207,14 +262,17 @@ private extension ShoppingModule {
|
|
|
207
262
|
if let name = variant.name {
|
|
208
263
|
pvBuild.name(name)
|
|
209
264
|
}
|
|
210
|
-
if let url = variant.url {
|
|
211
|
-
pvBuild.url(url)
|
|
212
|
-
}
|
|
213
265
|
if let price = variant.price {
|
|
214
266
|
if let amount = price.amount, let currencyCode = price.currencyCode {
|
|
215
267
|
pvBuild.formattedPrice(Decimal(amount), currencyCode: currencyCode)
|
|
216
268
|
}
|
|
217
269
|
}
|
|
270
|
+
if let url = variant.url {
|
|
271
|
+
pvBuild.url(url)
|
|
272
|
+
}
|
|
273
|
+
if let imageUrl = variant.imageUrl {
|
|
274
|
+
pvBuild.imageUrl(imageUrl)
|
|
275
|
+
}
|
|
218
276
|
let options = ShoppingModule.buildVariantOption(variant.options)
|
|
219
277
|
if let options = options {
|
|
220
278
|
pvBuild.options(options)
|
|
@@ -125,6 +125,17 @@ class FireworkSDK {
|
|
|
125
125
|
_FireworkSDKModule.default.setAppComponentName(value !== null && value !== void 0 ? value : '');
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Defaults to false. You can enable debug logs by setting this property to true.
|
|
130
|
+
*/
|
|
131
|
+
get debugLogsEnabled() {
|
|
132
|
+
return _FWLoggerUtil.default.enabled;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
set debugLogsEnabled(value) {
|
|
136
|
+
_FWLoggerUtil.default.enabled = value;
|
|
137
|
+
}
|
|
138
|
+
|
|
128
139
|
get eventEmitter() {
|
|
129
140
|
return _FireworkSDKModule.FireworkSDKModuleEventEmitter;
|
|
130
141
|
}
|
|
@@ -194,21 +205,21 @@ class FireworkSDK {
|
|
|
194
205
|
_FWLoggerUtil.default.logNativeMessage(event.message);
|
|
195
206
|
});
|
|
196
207
|
this.eventEmitter.addListener(_FWEventName.FWEventName.CustomCTAClick, event => {
|
|
197
|
-
_FWLoggerUtil.default.log(`Receive CustomCTAClick url ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
208
|
+
_FWLoggerUtil.default.log(`Receive CustomCTAClick url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
198
209
|
|
|
199
210
|
if (this.onCustomCTAClick) {
|
|
200
211
|
this.onCustomCTAClick(event !== null && event !== void 0 ? event : {});
|
|
201
212
|
}
|
|
202
213
|
});
|
|
203
214
|
this.eventEmitter.addListener(_FWEventName.FWEventName.VideoPlayback, event => {
|
|
204
|
-
_FWLoggerUtil.default.log(`Receive VideoPlayback event ${event === null || event === void 0 ? void 0 : event.eventName}`);
|
|
215
|
+
_FWLoggerUtil.default.log(`Receive VideoPlayback event eventName: ${event === null || event === void 0 ? void 0 : event.eventName}`);
|
|
205
216
|
|
|
206
217
|
if (this.onVideoPlayback) {
|
|
207
218
|
this.onVideoPlayback(event !== null && event !== void 0 ? event : {});
|
|
208
219
|
}
|
|
209
220
|
});
|
|
210
221
|
this.eventEmitter.addListener(_FWEventName.FWEventName.VideoFeedClick, event => {
|
|
211
|
-
_FWLoggerUtil.default.log(`Receive VideoFeedClick event ${event === null || event === void 0 ? void 0 : event.info.id}`);
|
|
222
|
+
_FWLoggerUtil.default.log(`Receive VideoFeedClick event id: ${event === null || event === void 0 ? void 0 : event.info.id}`);
|
|
212
223
|
|
|
213
224
|
if (this.onVideoFeedClick) {
|
|
214
225
|
this.onVideoFeedClick(event !== null && event !== void 0 ? event : {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FireworkSDK.ts"],"names":["FireworkSDK","onCustomCTAClick","_onCustomCTAClick","value","FWLoggerUtil","log","FireworkSDKModule","setCustomCTAClickEnabled","customCTALinkContentPageRouteName","_customCTALinkContentPageRouteName","setCustomCTALinkContentPageRouteName","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","setShareBaseURL","then","eventEmitter","emit","FWEventName","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","FireworkSDKModuleEventEmitter","shopping","VideoShopping","getInstance","liveStream","LiveStream","navigator","FWNavigator","_instance","constructor","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","ShoppingModule","LiveStreamModule","openVideoPlayer","config"],"mappings":";;;;;;;AACA;;AAGA;;AAQA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAUA;AACA;AACA;AACA,MAAMA,WAAN,CAAkB;AAGhB;AACF;AACA;;AAGE;AACF;A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A,KAAtB,GAA+B,EAA/B;AACD;AACF,KAND;AAOD;AAED;AACF;AACA;AACA;;;AACSc,EAAAA,IAAI,CAACC,MAAD,EAAkB;AAC3BlD,+BAAkBiD,IAAlB,CAAuBC,MAAvB;;AACAC,4BAAeF,IAAf;;AACAG,8BAAiBH,IAAjB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACSI,EAAAA,eAAe,CAACX,GAAD,EAAcY,MAAd,EAAiD;AACrEtD,+BAAkBqD,eAAlB,CAAkCX,GAAlC,EAAuCY,MAAvC,aAAuCA,MAAvC,cAAuCA,MAAvC,GAAiD,EAAjD;AACD;;AAtLe;;gBAAZ5D,W;;eAyLSA,W","sourcesContent":["import type { NativeEventEmitter } from 'react-native';\nimport LiveStream from './LiveStream';\n\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport VideoShopping from './VideoShopping';\nimport FWNavigator from './FWNavigator';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type CustomCTALinkContentRender = (\n event: CustomCTAClickEvent\n) => React.ReactNode | null;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n this._shareBaseURL = value;\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n this._adBadgeConfiguration = value;\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return VideoShopping.getInstance();\n }\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return LiveStream.getInstance();\n }\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return FWNavigator.getInstance();\n }\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(`Receive VideoPlayback event ${event?.eventName}`);\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
1
|
+
{"version":3,"sources":["FireworkSDK.ts"],"names":["FireworkSDK","onCustomCTAClick","_onCustomCTAClick","value","FWLoggerUtil","log","FireworkSDKModule","setCustomCTAClickEnabled","customCTALinkContentPageRouteName","_customCTALinkContentPageRouteName","setCustomCTALinkContentPageRouteName","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","setShareBaseURL","then","eventEmitter","emit","FWEventName","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","debugLogsEnabled","enabled","FireworkSDKModuleEventEmitter","shopping","VideoShopping","getInstance","liveStream","LiveStream","navigator","FWNavigator","_instance","constructor","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","ShoppingModule","LiveStreamModule","openVideoPlayer","config"],"mappings":";;;;;;;AACA;;AAGA;;AAQA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAUA;AACA;AACA;AACA,MAAMA,WAAN,CAAkB;AAGhB;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AAC6B,MAAhBC,gBAAgB,GAAuC;AAChE,WAAO,KAAKC,iBAAZ;AACD;;AAC0B,MAAhBD,gBAAgB,CAACE,KAAD,EAA4C;AACrEC,0BAAaC,GAAb,CAAkB,iCAAgC,CAAC,CAACF,KAAM,EAA1D;;AAC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/B;AACD;AACF,KAND;AAOD;AAED;AACF;AACA;AACA;;;AACSc,EAAAA,IAAI,CAACC,MAAD,EAAkB;AAC3BpD,+BAAkBmD,IAAlB,CAAuBC,MAAvB;;AACAC,4BAAeF,IAAf;;AACAG,8BAAiBH,IAAjB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACSI,EAAAA,eAAe,CAACX,GAAD,EAAcY,MAAd,EAAiD;AACrExD,+BAAkBuD,eAAlB,CAAkCX,GAAlC,EAAuCY,MAAvC,aAAuCA,MAAvC,cAAuCA,MAAvC,GAAiD,EAAjD;AACD;;AAlMe;;gBAAZ9D,W;;eAqMSA,W","sourcesContent":["import type { NativeEventEmitter } from 'react-native';\nimport LiveStream from './LiveStream';\n\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport VideoShopping from './VideoShopping';\nimport FWNavigator from './FWNavigator';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type CustomCTALinkContentRender = (\n event: CustomCTAClickEvent\n) => React.ReactNode | null;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n this._shareBaseURL = value;\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n this._adBadgeConfiguration = value;\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n /**\n * Defaults to false. You can enable debug logs by setting this property to true.\n */\n public get debugLogsEnabled(): boolean {\n return FWLoggerUtil.enabled;\n }\n public set debugLogsEnabled(value: boolean) {\n FWLoggerUtil.enabled = value;\n }\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return VideoShopping.getInstance();\n }\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return LiveStream.getInstance();\n }\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return FWNavigator.getInstance();\n }\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url: ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(\n `Receive VideoPlayback event eventName: ${event?.eventName}`\n );\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n}\n\nexport default FireworkSDK;\n"]}
|