react-native-firework-sdk 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/android/build.gradle +0 -1
  2. package/ios/Components/AdConfiguration.swift +20 -0
  3. package/ios/Components/StoryBlock.swift +7 -6
  4. package/ios/Components/StoryBlockManager.swift +2 -2
  5. package/ios/Components/VideoFeed.swift +128 -75
  6. package/ios/Components/VideoFeedConfiguration.swift +4 -3
  7. package/ios/Components/VideoFeedManager.m +5 -0
  8. package/ios/Components/VideoFeedManager.swift +9 -10
  9. package/ios/Components/VideoPlayerConfiguration.swift +1 -1
  10. package/ios/FireworkSdk.xcodeproj/project.pbxproj +11 -3
  11. package/ios/Models/NativeToRN/FireworkEventName.swift +25 -25
  12. package/ios/Models/NativeToRN/FireworkSDK+Json.swift +39 -21
  13. package/ios/Models/RNToNative/RCTConvert+FireworkSDKModule.swift +42 -16
  14. package/ios/Models/RNToNative/RCTConvert+Shopping.swift +13 -11
  15. package/ios/Models/RNToNative/RCTConvert+StoryBlock.swift +8 -6
  16. package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +41 -22
  17. package/ios/Modules/FWNavigatorModule/FWNavigatorContainerViewController.swift +4 -3
  18. package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +55 -19
  19. package/ios/Modules/FWNavigatorModule/FWNavigatorProtocol.swift +7 -3
  20. package/ios/Modules/FireworkSDKModule/AdBadgeConfiguration.swift +2 -1
  21. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +15 -9
  22. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +79 -28
  23. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -0
  24. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +94 -45
  25. package/ios/Modules/FireworkSDKModule/TrackPurchaseParameters.swift +16 -0
  26. package/ios/Modules/LiveStream/LiveStreamModule.swift +32 -10
  27. package/ios/Modules/Shopping/FWCartViewController.swift +14 -12
  28. package/ios/Modules/Shopping/Product.swift +3 -3
  29. package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +2 -2
  30. package/ios/Modules/Shopping/ShoppingModule.swift +147 -100
  31. package/ios/Utils/String+Color.swift +13 -5
  32. package/ios/Utils/UIView+Constraints.swift +34 -21
  33. package/ios/Utils/UIViewController+AttachChild.swift +13 -11
  34. package/lib/commonjs/FireworkSDK.js +9 -0
  35. package/lib/commonjs/FireworkSDK.js.map +1 -1
  36. package/lib/commonjs/components/VideoFeed.js +41 -3
  37. package/lib/commonjs/components/VideoFeed.js.map +1 -1
  38. package/lib/commonjs/index.js.map +1 -1
  39. package/lib/commonjs/models/AdConfiguration.js +2 -0
  40. package/lib/commonjs/models/AdConfiguration.js.map +1 -0
  41. package/lib/commonjs/models/TrackPurchaseParameters.js +2 -0
  42. package/lib/commonjs/models/TrackPurchaseParameters.js.map +1 -0
  43. package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
  44. package/lib/module/FireworkSDK.js +9 -0
  45. package/lib/module/FireworkSDK.js.map +1 -1
  46. package/lib/module/components/VideoFeed.js +42 -5
  47. package/lib/module/components/VideoFeed.js.map +1 -1
  48. package/lib/module/index.js.map +1 -1
  49. package/lib/module/models/AdConfiguration.js +2 -0
  50. package/lib/module/models/AdConfiguration.js.map +1 -0
  51. package/lib/module/models/TrackPurchaseParameters.js +2 -0
  52. package/lib/module/models/TrackPurchaseParameters.js.map +1 -0
  53. package/lib/module/modules/FireworkSDKModule.js.map +1 -1
  54. package/lib/typescript/FireworkSDK.d.ts +6 -0
  55. package/lib/typescript/components/VideoFeed.d.ts +6 -0
  56. package/lib/typescript/index.d.ts +4 -1
  57. package/lib/typescript/models/AdConfiguration.d.ts +22 -0
  58. package/lib/typescript/models/TrackPurchaseParameters.d.ts +26 -0
  59. package/lib/typescript/models/VideoFeedConfiguration.d.ts +4 -0
  60. package/lib/typescript/modules/FireworkSDKModule.d.ts +2 -0
  61. package/package.json +1 -1
  62. package/react-native-firework-sdk.podspec +1 -1
  63. package/src/FireworkSDK.ts +9 -0
  64. package/src/components/VideoFeed.tsx +35 -1
  65. package/src/index.tsx +6 -0
  66. package/src/models/AdConfiguration.ts +23 -0
  67. package/src/models/TrackPurchaseParameters.ts +24 -0
  68. package/src/models/VideoFeedConfiguration.ts +4 -0
  69. package/src/modules/FireworkSDKModule.ts +2 -0
@@ -5,25 +5,31 @@
5
5
  // Created by Jeff Zheng on 2021/12/21.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import FireworkVideo
9
+ import Foundation
10
10
 
11
11
  extension FireworkSDKModule: FireworkVideoCTADelegate {
12
12
  func handleCustomCTAClick(_ viewController: PlayerViewController, url: URL) -> Bool {
13
13
  #if DEBUG
14
- let formatter = DateFormatter()
15
- formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
16
- sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": "[iOS] Receive CustomCTAClick event \(formatter.string(from: Date()))"])
14
+ let formatter = DateFormatter()
15
+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
16
+ sendEvent(
17
+ withName: FWEventName.logMessage.rawValue,
18
+ body: [
19
+ "message":
20
+ "[iOS] Receive CustomCTAClick event \(formatter.string(from: Date()))"
21
+ ])
17
22
  #endif
18
23
 
19
- sendEvent(withName: FWEventName.CustomCTAClick.rawValue, body: ["url": url.absoluteString])
24
+ sendEvent(withName: FWEventName.customCTAClick.rawValue, body: ["url": url.absoluteString])
20
25
 
21
26
  var customCTALinkContentPageEnabled = false
22
27
  if let moduleName = gAppComponentName,
23
- moduleName.count > 0,
28
+ moduleName.count > 0,
24
29
  let initialRouteName = customCTALinkContentPageRouteName,
25
- initialRouteName.count > 0,
26
- let presentedVC = RCTPresentedViewController() {
30
+ initialRouteName.count > 0,
31
+ let presentedVC = RCTPresentedViewController()
32
+ {
27
33
  customCTALinkContentPageEnabled = true
28
34
  let containerViewController = FWNavigatorContainerViewController()
29
35
  containerViewController.moduleName = moduleName
@@ -36,7 +42,7 @@ extension FireworkSDKModule: FireworkVideoCTADelegate {
36
42
 
37
43
  }
38
44
  }
39
-
45
+
40
46
  return customCTAClickEnabled || customCTALinkContentPageEnabled
41
47
  }
42
48
  }
@@ -5,76 +5,127 @@
5
5
  // Created by Jeff Zheng on 2021/12/21.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import FireworkVideo
9
+ import Foundation
10
10
 
11
11
  extension FireworkSDKModule: FireworkVideoPlaybackDelegate {
12
12
  func fireworkVideoDidPause(_ videoPlayback: VideoPlaybackDetails) {
13
-
13
+
14
14
  }
15
-
15
+
16
16
  func fireworkVideoDidResume(_ videoPlayback: VideoPlaybackDetails) {
17
-
17
+
18
18
  }
19
-
19
+
20
20
  func fireworkVideoDidRecordImpression(_ videoPlayback: VideoPlaybackDetails) {
21
21
  guard enableVideoPlayBackEvent else { return }
22
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName": VideoPlaybackSubEventName.Impression.rawValue, "info": videoPlayback.jsObject])
22
+ sendEvent(
23
+ withName: FWEventName.videoPlayback.rawValue,
24
+ body: [
25
+ "eventName": VideoPlaybackSubEventName.impression.rawValue,
26
+ "info": videoPlayback.jsObject
27
+ ])
23
28
  }
24
-
29
+
25
30
  func fireworkVideoDidStartPlaying(_ videoPlayback: VideoPlaybackDetails) {
26
31
  guard enableVideoPlayBackEvent else { return }
27
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName":VideoPlaybackSubEventName.Start.rawValue, "info": videoPlayback.jsObject])
32
+ sendEvent(
33
+ withName: FWEventName.videoPlayback.rawValue,
34
+ body: [
35
+ "eventName": VideoPlaybackSubEventName.start.rawValue,
36
+ "info": videoPlayback.jsObject
37
+ ])
28
38
  }
29
-
39
+
30
40
  func fireworkVideoReachedFirstQuartile(_ videoPlayback: VideoPlaybackDetails) {
31
41
  guard enableVideoPlayBackEvent else { return }
32
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName":VideoPlaybackSubEventName.FirstQuartile.rawValue, "info": videoPlayback.jsObject])
42
+ sendEvent(
43
+ withName: FWEventName.videoPlayback.rawValue,
44
+ body: [
45
+ "eventName": VideoPlaybackSubEventName.firstQuartile.rawValue,
46
+ "info": videoPlayback.jsObject
47
+ ])
33
48
  }
34
-
49
+
35
50
  func fireworkVideoReachedMidPoint(_ videoPlayback: VideoPlaybackDetails) {
36
51
  guard enableVideoPlayBackEvent else { return }
37
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName":VideoPlaybackSubEventName.Midpoint.rawValue, "info": videoPlayback.jsObject])
52
+ sendEvent(
53
+ withName: FWEventName.videoPlayback.rawValue,
54
+ body: [
55
+ "eventName": VideoPlaybackSubEventName.midpoint.rawValue,
56
+ "info": videoPlayback.jsObject
57
+ ])
38
58
  }
39
-
59
+
40
60
  func fireworkVideoReachedThirdQuartile(_ videoPlayback: VideoPlaybackDetails) {
41
61
  guard enableVideoPlayBackEvent else { return }
42
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName":VideoPlaybackSubEventName.ThirdQuartile.rawValue, "info": videoPlayback.jsObject])
62
+ sendEvent(
63
+ withName: FWEventName.videoPlayback.rawValue,
64
+ body: [
65
+ "eventName": VideoPlaybackSubEventName.thirdQuartile.rawValue,
66
+ "info": videoPlayback.jsObject
67
+ ])
43
68
  }
44
-
69
+
45
70
  func fireworkVideoDidFinishPlaying(_ videoPlayback: VideoPlaybackDetails) {
46
71
  guard enableVideoPlayBackEvent else { return }
47
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName":VideoPlaybackSubEventName.Complete.rawValue, "info": videoPlayback.jsObject])
72
+ sendEvent(
73
+ withName: FWEventName.videoPlayback.rawValue,
74
+ body: [
75
+ "eventName": VideoPlaybackSubEventName.complete.rawValue,
76
+ "info": videoPlayback.jsObject
77
+ ])
48
78
  }
49
-
79
+
50
80
  func fireworkVideoDidTapCTAButton(_ videoPlayback: VideoPlaybackDetails) {
51
81
  guard enableVideoPlayBackEvent else { return }
52
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName":VideoPlaybackSubEventName.ClickCTA.rawValue, "info": videoPlayback.jsObject])
82
+ sendEvent(
83
+ withName: FWEventName.videoPlayback.rawValue,
84
+ body: [
85
+ "eventName": VideoPlaybackSubEventName.clickCTA.rawValue,
86
+ "info": videoPlayback.jsObject
87
+ ])
53
88
  }
54
-
89
+
55
90
  func fireworkVideoDidTapShareButton(_ videoPlayback: VideoPlaybackDetails) {
56
91
  guard enableVideoPlayBackEvent else { return }
57
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName":VideoPlaybackSubEventName.ClickShare.rawValue, "info": videoPlayback.jsObject])
92
+ sendEvent(
93
+ withName: FWEventName.videoPlayback.rawValue,
94
+ body: [
95
+ "eventName": VideoPlaybackSubEventName.clickShare.rawValue,
96
+ "info": videoPlayback.jsObject
97
+ ])
58
98
  }
59
-
99
+
60
100
  func fireworkVideoDidStartPlayingAd(_ videoPlayback: VideoPlaybackDetails) {
61
-
101
+
62
102
  }
63
-
103
+
64
104
  func fireworkVideoDidFinishPlayingAd(_ videoPlayback: VideoPlaybackDetails) {
65
105
  guard enableVideoPlayBackEvent else { return }
66
- sendEvent(withName: FWEventName.VideoPlayback.rawValue, body: ["eventName":VideoPlaybackSubEventName.AdEnd.rawValue, "info": videoPlayback.jsObject])
106
+ sendEvent(
107
+ withName: FWEventName.videoPlayback.rawValue,
108
+ body: [
109
+ "eventName": VideoPlaybackSubEventName.adEnd.rawValue,
110
+ "info": videoPlayback.jsObject
111
+ ])
67
112
  }
68
113
  }
69
114
 
70
115
  extension FireworkSDKModule: FireworkVideoFeedDelegate {
71
116
  func fireworkVideoDidTapThumbnail(_ eventDetails: FeedEventDetails) {
72
117
  #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()))"])
118
+ let formatter = DateFormatter()
119
+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
120
+ sendEvent(
121
+ withName: FWEventName.logMessage.rawValue,
122
+ body: [
123
+ "message":
124
+ "[iOS] Send VideoFeedClick event id: \(eventDetails.id) \(formatter.string(from: Date()))"
125
+ ])
76
126
  #endif
77
127
 
78
- sendEvent(withName: FWEventName.VideoFeedClick.rawValue, body: ["info": eventDetails.jsObject])
128
+ sendEvent(
129
+ withName: FWEventName.videoFeedClick.rawValue, body: ["info": eventDetails.jsObject])
79
130
  }
80
131
  }
@@ -18,5 +18,6 @@ RCT_EXTERN_METHOD(setShareBaseURL:(NSString *)url resolver: (RCTPromiseResolveBl
18
18
  RCT_EXTERN_METHOD(setVideoPlaybackEventEnabled:(BOOL)enabled)
19
19
  RCT_EXTERN_METHOD(setAdBadgeConfiguration:(NSDictionary *)config resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
20
20
  RCT_EXTERN_METHOD(setAppComponentName:(NSString *)name resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
21
+ RCT_EXTERN_METHOD(trackPurchase:(NSDictionary *)parameters)
21
22
 
22
23
  @end
@@ -6,7 +6,6 @@
6
6
  //
7
7
  // The FireworkSDKModule Wrap native FireworkVideoSDK class,then expose to JavaScript in Objective-C
8
8
 
9
-
10
9
  import FireworkVideo
11
10
 
12
11
  var gShareBaseURL: String?
@@ -15,32 +14,32 @@ var gAppComponentName: String?
15
14
 
16
15
  @objc(FireworkSDKModule)
17
16
  class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
18
- // var shareBaseURL: String?
17
+ // var shareBaseURL: String?
19
18
  var customCTAClickEnabled: Bool = false
20
19
 
21
20
  var customCTALinkContentPageRouteName: String?
22
21
 
23
22
  /// Decide whether to send video playback event to RN.
24
23
  var enableVideoPlayBackEvent: Bool = false
25
-
24
+
26
25
  override func supportedEvents() -> [String]! {
27
26
  FWEventName.allCases.map { $0.rawValue }
28
27
  }
29
-
28
+
30
29
  override class func requiresMainQueueSetup() -> Bool {
31
30
  return true
32
31
  }
33
-
32
+
34
33
  @objc(initializeSDK:)
35
34
  func initializeSDK(_ userId: String? = nil) {
36
35
  #if DEBUG
37
- let formatter = DateFormatter()
38
- formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
36
+ let formatter = DateFormatter()
37
+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
38
+
39
+ let message = "[iOS] Call initializeSDK \(formatter.string(from: Date()))"
40
+ print("[react-native-firework-sdk] [swift] \(message)")
39
41
 
40
- let message = "[iOS] Call initializeSDK \(formatter.string(from: Date()))"
41
- print("[react-native-firework-sdk] [swift] \(message)")
42
-
43
- sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": message])
42
+ sendEvent(withName: FWEventName.logMessage.rawValue, body: ["message": message])
44
43
  #endif
45
44
 
46
45
  DispatchQueue.main.async {
@@ -50,13 +49,13 @@ class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
50
49
  FireworkVideoSDK.eventTracking.feedDelegate = self
51
50
  }
52
51
  }
53
-
52
+
54
53
  @objc(openVideoPlayer:config:)
55
- func openVideoPlayer(_ url: String, config: [String:AnyObject]) {
54
+ func openVideoPlayer(_ url: String, config: [String: AnyObject]) {
56
55
  guard let urlString = URL.init(string: url) else {
57
56
  return
58
57
  }
59
-
58
+
60
59
  var finalConfig = RCTConvert.videoPlayerContentConfiguration(config)
61
60
  if let baseUrl = gShareBaseURL {
62
61
  finalConfig.shareButton.behavior.baseURL = URL(string: baseUrl)
@@ -65,9 +64,9 @@ class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
65
64
  var feedContentConfig = VideoFeedContentConfiguration()
66
65
  feedContentConfig.playerView = finalConfig
67
66
  if let adBadge = FireworkSDKModule.convertToFWAdBadgeConfiguration(gAdBadgeConfiguration) {
68
- feedContentConfig.adBadge = adBadge;
67
+ feedContentConfig.adBadge = adBadge
69
68
  }
70
-
69
+
71
70
  DispatchQueue.main.async {
72
71
  guard let presentedVC = RCTPresentedViewController() else {
73
72
  return
@@ -78,73 +77,122 @@ class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
78
77
  }
79
78
  }
80
79
  }
81
-
80
+
82
81
  @objc(setCustomCTAClickEnabled:)
83
82
  func setCustomCTAClickEnabled(_ enabled: Bool) {
84
83
  customCTAClickEnabled = enabled
85
84
  }
86
85
 
87
86
  @objc(setCustomCTALinkContentPageRouteName:resolver:rejecter:)
88
- func setCustomCTALinkContentPageRouteName(_ name: String, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock) {
87
+ func setCustomCTALinkContentPageRouteName(
88
+ _ name: String, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock
89
+ ) {
89
90
  customCTALinkContentPageRouteName = name
90
91
  resolver([:])
91
92
  }
92
-
93
+
93
94
  @objc(setShareBaseURL:resolver:rejecter:)
94
- func setShareBaseURL(_ url: String, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock) {
95
+ func setShareBaseURL(
96
+ _ url: String, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock
97
+ ) {
95
98
  gShareBaseURL = url
96
99
  resolver([:])
97
100
  }
98
-
101
+
99
102
  @objc(setVideoPlaybackEventEnabled:)
100
103
  func setVideoPlaybackEventEnabled(_ enable: Bool) {
101
104
  enableVideoPlayBackEvent = enable
102
105
  }
103
-
106
+
104
107
  @objc(setAdBadgeConfiguration:resolver:rejecter:)
105
- func setAdBadgeConfiguration(_ config: [String: AnyObject]? = nil, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock) {
108
+ func setAdBadgeConfiguration(
109
+ _ config: [String: AnyObject]? = nil, resolver: RCTPromiseResolveBlock,
110
+ rejecter: RCTPromiseRejectBlock
111
+ ) {
106
112
  gAdBadgeConfiguration = RCTConvert.adBadgeConfiguration(config)
107
113
  resolver([:])
108
114
  }
109
115
 
110
116
  @objc(setAppComponentName:resolver:rejecter:)
111
- func setAppComponentName(_ name: String, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock) {
117
+ func setAppComponentName(
118
+ _ name: String, resolver: RCTPromiseResolveBlock, rejecter: RCTPromiseRejectBlock
119
+ ) {
112
120
  gAppComponentName = name
113
121
  resolver([:])
114
122
  }
115
-
123
+
124
+ @objc(trackPurchase:)
125
+ func trackPurchase(_ parameters: [String: AnyObject]?) {
126
+ guard let trackPurchaseParameters = RCTConvert.trackPurchaseParameters(parameters) else {
127
+ #if DEBUG
128
+ let formatter = DateFormatter()
129
+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
130
+
131
+ let message = """
132
+ "[iOS] Fail to parse parameters of trackPurchase \
133
+ method: \(String(describing: parameters)) \(formatter.string(from: Date()))
134
+ """
135
+ print("[react-native-firework-sdk] [swift] \(message)")
136
+
137
+ sendEvent(withName: FWEventName.logMessage.rawValue, body: ["message": message])
138
+ #endif
139
+ return
140
+ }
141
+ FireworkVideoSDK.trackPurchase(
142
+ orderID: trackPurchaseParameters.orderId,
143
+ value: trackPurchaseParameters.value,
144
+ currencyCode: trackPurchaseParameters.currencyCode,
145
+ countryCode: trackPurchaseParameters.countryCode,
146
+ trackPurchaseParameters.additionalInfo
147
+ )
148
+ }
149
+
116
150
  // MARK: - FireworkVideoSDKDelegate
117
151
  func fireworkVideoDidLoadSuccessfully() {
118
152
  #if DEBUG
119
- let formatter = DateFormatter()
120
- formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
153
+ let formatter = DateFormatter()
154
+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
121
155
 
122
- let message = "[iOS] Send SDK initialization successful event \(formatter.string(from: Date()))"
123
- print("[react-native-firework-sdk] [swift] \(message)")
156
+ let message =
157
+ "[iOS] Send SDK initialization successful event \(formatter.string(from: Date()))"
158
+ print("[react-native-firework-sdk] [swift] \(message)")
124
159
 
125
- sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": message])
160
+ sendEvent(withName: FWEventName.logMessage.rawValue, body: ["message": message])
126
161
  #endif
127
162
 
128
- sendEvent(withName: FWEventName.SDKInit.rawValue, body: [:])
163
+ sendEvent(withName: FWEventName.sdkInit.rawValue, body: [:])
129
164
  }
130
-
165
+
131
166
  func fireworkVideoDidLoadWith(error: FireworkVideoSDKError) {
132
167
  #if DEBUG
133
- let formatter = DateFormatter()
134
- formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
135
-
136
- let message = "[iOS] Send SDK initialization failure event \(formatter.string(from: Date()))"
137
- print("[react-native-firework-sdk] [swift] \(message)")
138
-
139
- sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": "[iOS] Send SDK initialization failure event \(formatter.string(from: Date()))"])
168
+ let formatter = DateFormatter()
169
+ formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
170
+
171
+ let message =
172
+ "[iOS] Send SDK initialization failure event \(formatter.string(from: Date()))"
173
+ print("[react-native-firework-sdk] [swift] \(message)")
174
+
175
+ sendEvent(
176
+ withName: FWEventName.logMessage.rawValue,
177
+ body: [
178
+ "message":
179
+ "[iOS] Send SDK initialization failure event \(formatter.string(from: Date()))"
180
+ ])
140
181
  #endif
141
182
 
142
- sendEvent(withName: FWEventName.SDKInit.rawValue, body: ["error": ["name": error.jsErrorName, "reason": error.recoverySuggestion ?? "default"]])
183
+ sendEvent(
184
+ withName: FWEventName.sdkInit.rawValue,
185
+ body: [
186
+ "error": [
187
+ "name": error.jsErrorName, "reason": error.recoverySuggestion ?? "default"
188
+ ]
189
+ ])
143
190
  }
144
191
  }
145
192
 
146
193
  extension FireworkSDKModule {
147
- static func convertToFWAdBadgeConfiguration(_ adBadgeConfiguration: AdBadgeConfiguration?) -> FireworkVideo.AdBadgeConfiguration? {
194
+ static func convertToFWAdBadgeConfiguration(_ adBadgeConfiguration: AdBadgeConfiguration?)
195
+ -> FireworkVideo.AdBadgeConfiguration? {
148
196
  guard let adBadgeConfiguration = adBadgeConfiguration else {
149
197
  return nil
150
198
  }
@@ -157,10 +205,11 @@ extension FireworkSDKModule {
157
205
  fwAdBadgeConfiguration.backgroundColor = backgroundColor.uicolor()
158
206
  }
159
207
  switch adBadgeConfiguration.badgeTextType {
160
- case .sponsored:
161
- fwAdBadgeConfiguration.badgeText = FireworkVideo.AdBadgeConfiguration.BadgeText.sponsored
162
- default:
163
- fwAdBadgeConfiguration.badgeText = FireworkVideo.AdBadgeConfiguration.BadgeText.ad
208
+ case .sponsored:
209
+ fwAdBadgeConfiguration.badgeText =
210
+ FireworkVideo.AdBadgeConfiguration.BadgeText.sponsored
211
+ default:
212
+ fwAdBadgeConfiguration.badgeText = FireworkVideo.AdBadgeConfiguration.BadgeText.ad
164
213
  }
165
214
 
166
215
  return fwAdBadgeConfiguration
@@ -0,0 +1,16 @@
1
+ //
2
+ // TrackPurchaseParameters.swift
3
+ // react-native-firework-sdk
4
+ //
5
+ // Created by linjie jiang on 2022/9/27.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ struct TrackPurchaseParameters: Codable {
11
+ var orderId: String
12
+ var value: Double?
13
+ var currencyCode: String?
14
+ var countryCode: String?
15
+ var additionalInfo: [String: String]?
16
+ }
@@ -5,20 +5,20 @@
5
5
  // Created by Jeff Zheng on 2022/2/16.
6
6
  //
7
7
 
8
- import Foundation
9
8
  import FireworkVideo
9
+ import Foundation
10
10
 
11
11
  @objc(LiveStreamModule)
12
- class LiveStreamModule: RCTEventEmitter , FireworkLiveStreamEventDelegate {
13
-
12
+ class LiveStreamModule: RCTEventEmitter, FireworkLiveStreamEventDelegate {
13
+
14
14
  override func supportedEvents() -> [String]! {
15
15
  LiveStreamEventName.allCases.map { $0.rawValue }
16
16
  }
17
-
17
+
18
18
  override class func requiresMainQueueSetup() -> Bool {
19
19
  return true
20
20
  }
21
-
21
+
22
22
  @objc
23
23
  func initialize() {
24
24
  DispatchQueue.main.async {
@@ -26,18 +26,40 @@ class LiveStreamModule: RCTEventEmitter , FireworkLiveStreamEventDelegate {
26
26
  }
27
27
  }
28
28
  func fireworkLiveStreamUserDidJoin(_ liveStream: LiveStreamEventDetails) {
29
- sendEvent(withName: LiveStreamEventName.livestream.rawValue, body: ["eventName": LiveStreamSubEventName.UserDidjoin.rawValue, "info": liveStream.jsObject])
29
+ sendEvent(
30
+ withName: LiveStreamEventName.livestream.rawValue,
31
+ body: [
32
+ "eventName": LiveStreamSubEventName.userDidjoin.rawValue,
33
+ "info": liveStream.jsObject
34
+ ])
30
35
  }
31
36
 
32
37
  func fireworkLiveStreamUserDidLeave(_ liveStream: LiveStreamEventDetails) {
33
- sendEvent(withName: LiveStreamEventName.livestream.rawValue, body: ["eventName": LiveStreamSubEventName.UserDidLeave.rawValue, "info": liveStream.jsObject])
38
+ sendEvent(
39
+ withName: LiveStreamEventName.livestream.rawValue,
40
+ body: [
41
+ "eventName": LiveStreamSubEventName.userDidLeave.rawValue,
42
+ "info": liveStream.jsObject
43
+ ])
34
44
  }
35
45
 
36
- func fireworkLiveStreamUserDidSendChat(_ message: LiveStreamMessageDetails, to liveStream: LiveStreamEventDetails) {
37
- sendEvent(withName: LiveStreamEventName.livestreamChat.rawValue, body: ["eventName": LiveStreamChatSubEventName.UserSendChat.rawValue, "message": message.jsObject, "liveStream": liveStream.jsObject])
46
+ func fireworkLiveStreamUserDidSendChat(
47
+ _ message: LiveStreamMessageDetails, to liveStream: LiveStreamEventDetails
48
+ ) {
49
+ sendEvent(
50
+ withName: LiveStreamEventName.livestreamChat.rawValue,
51
+ body: [
52
+ "eventName": LiveStreamChatSubEventName.userSendChat.rawValue,
53
+ "message": message.jsObject, "liveStream": liveStream.jsObject
54
+ ])
38
55
  }
39
56
 
40
57
  func fireworkLiveStreamUserDidSendLike(_ liveStream: LiveStreamEventDetails) {
41
- sendEvent(withName: LiveStreamEventName.livestream.rawValue, body: ["eventName": LiveStreamSubEventName.UserSendLike.rawValue, "info": liveStream.jsObject])
58
+ sendEvent(
59
+ withName: LiveStreamEventName.livestream.rawValue,
60
+ body: [
61
+ "eventName": LiveStreamSubEventName.userSendLike.rawValue,
62
+ "info": liveStream.jsObject
63
+ ])
42
64
  }
43
65
  }
@@ -5,8 +5,8 @@
5
5
  // Created by Jeff Zheng on 2021/12/31.
6
6
  //
7
7
 
8
- import UIKit
9
8
  import FireworkVideo
9
+ import UIKit
10
10
 
11
11
  @objc(FWCartViewController)
12
12
  public class FWCartViewController: UIViewController, CartViewRepresentable {
@@ -14,27 +14,29 @@ public class FWCartViewController: UIViewController, CartViewRepresentable {
14
14
  @objc public var enableShowCustomCartView: Bool = true
15
15
  private var properties: [String: Any] = [:]
16
16
  private var directShowCartPage = false
17
-
17
+
18
18
  init(callbackId: Int, enableShowCustomCartView: Bool) {
19
19
  self.callbackId = callbackId
20
20
  self.enableShowCustomCartView = enableShowCustomCartView
21
21
  super.init(nibName: nil, bundle: nil)
22
22
  if enableShowCustomCartView {
23
- NotificationCenter.default.addObserver(self, selector: #selector(showCustomCartView), name: Notification.Name(rawValue: "showCustomCartView"), object: nil)
23
+ NotificationCenter.default.addObserver(
24
+ self, selector: #selector(showCustomCartView),
25
+ name: Notification.Name(rawValue: "showCustomCartView"), object: nil)
24
26
  }
25
27
  }
26
-
28
+
27
29
  required init?(coder: NSCoder) {
28
30
  super.init(coder: coder)
29
31
  }
30
-
32
+
31
33
  public override func viewWillAppear(_ animated: Bool) {
32
34
  super.viewWillAppear(animated)
33
35
  if enableShowCustomCartView {
34
36
  self.navigationController?.setNavigationBarHidden(true, animated: true)
35
37
  }
36
38
  }
37
-
39
+
38
40
  public override func viewDidLoad() {
39
41
  super.viewDidLoad()
40
42
 
@@ -42,30 +44,30 @@ public class FWCartViewController: UIViewController, CartViewRepresentable {
42
44
  directShowCustomCartView()
43
45
  }
44
46
  }
45
-
47
+
46
48
  public override func viewWillDisappear(_ animated: Bool) {
47
49
  super.viewWillDisappear(animated)
48
50
  if enableShowCustomCartView {
49
51
  self.navigationController?.setNavigationBarHidden(false, animated: true)
50
52
  }
51
53
  }
52
-
54
+
53
55
  @objc func showCustomCartView(_ noti: NSNotification) {
54
- guard let cbId = noti.userInfo?["cbId"] as? Int, callbackId == cbId else {
56
+ guard let cbId = noti.userInfo?["cbId"] as? Int, callbackId == cbId else {
55
57
  return
56
58
  }
57
59
 
58
60
  if let properties = noti.userInfo?["properties"] as? [String: Any] {
59
61
  self.properties = properties
60
62
  }
61
-
63
+
62
64
  if isViewLoaded {
63
65
  directShowCustomCartView()
64
66
  } else {
65
67
  directShowCartPage = true
66
68
  }
67
69
  }
68
-
70
+
69
71
  private func directShowCustomCartView() {
70
72
  guard let appComponentName = gAppComponentName, appComponentName.count > 0 else {
71
73
  return
@@ -76,7 +78,7 @@ public class FWCartViewController: UIViewController, CartViewRepresentable {
76
78
  initialProperties: properties)
77
79
  view.addSubview(rctRootView)
78
80
  rctRootView.translatesAutoresizingMaskIntoConstraints = false
79
-
81
+
80
82
  NSLayoutConstraint.activate([
81
83
  rctRootView.leftAnchor.constraint(equalTo: view.leftAnchor),
82
84
  rctRootView.topAnchor.constraint(equalTo: view.topAnchor),
@@ -12,7 +12,7 @@ struct Product: Codable {
12
12
  var name: String?
13
13
  var description: String?
14
14
  var units: [ProductUnit]?
15
-
15
+
16
16
  struct ProductUnit: Codable {
17
17
  var unitId: String
18
18
  var name: String?
@@ -21,12 +21,12 @@ struct Product: Codable {
21
21
  var imageUrl: String?
22
22
  var options: [VariantOption]?
23
23
  }
24
-
24
+
25
25
  struct Price: Codable {
26
26
  var amount: Double?
27
27
  var currencyCode: String?
28
28
  }
29
-
29
+
30
30
  struct VariantOption: Codable, Equatable {
31
31
  var name: String?
32
32
  var value: String?
@@ -9,11 +9,11 @@ import Foundation
9
9
 
10
10
  struct ProductInfoViewConfiguration: Codable {
11
11
  var addToCartButton: ButtonConfiguration?
12
-
12
+
13
13
  struct ButtonConfiguration: Codable {
14
14
  var backgroundColor: String?
15
15
  var textColor: String?
16
16
  var fontSize: Double?
17
17
  }
18
-
18
+
19
19
  }