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.
- package/android/build.gradle +0 -1
- package/ios/Components/AdConfiguration.swift +20 -0
- package/ios/Components/StoryBlock.swift +7 -6
- package/ios/Components/StoryBlockManager.swift +2 -2
- package/ios/Components/VideoFeed.swift +128 -75
- package/ios/Components/VideoFeedConfiguration.swift +4 -3
- package/ios/Components/VideoFeedManager.m +5 -0
- package/ios/Components/VideoFeedManager.swift +9 -10
- package/ios/Components/VideoPlayerConfiguration.swift +1 -1
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +11 -3
- package/ios/Models/NativeToRN/FireworkEventName.swift +25 -25
- package/ios/Models/NativeToRN/FireworkSDK+Json.swift +39 -21
- package/ios/Models/RNToNative/RCTConvert+FireworkSDKModule.swift +42 -16
- package/ios/Models/RNToNative/RCTConvert+Shopping.swift +13 -11
- package/ios/Models/RNToNative/RCTConvert+StoryBlock.swift +8 -6
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +41 -22
- package/ios/Modules/FWNavigatorModule/FWNavigatorContainerViewController.swift +4 -3
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +55 -19
- package/ios/Modules/FWNavigatorModule/FWNavigatorProtocol.swift +7 -3
- package/ios/Modules/FireworkSDKModule/AdBadgeConfiguration.swift +2 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +15 -9
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +79 -28
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +94 -45
- package/ios/Modules/FireworkSDKModule/TrackPurchaseParameters.swift +16 -0
- package/ios/Modules/LiveStream/LiveStreamModule.swift +32 -10
- package/ios/Modules/Shopping/FWCartViewController.swift +14 -12
- package/ios/Modules/Shopping/Product.swift +3 -3
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +2 -2
- package/ios/Modules/Shopping/ShoppingModule.swift +147 -100
- package/ios/Utils/String+Color.swift +13 -5
- package/ios/Utils/UIView+Constraints.swift +34 -21
- package/ios/Utils/UIViewController+AttachChild.swift +13 -11
- package/lib/commonjs/FireworkSDK.js +9 -0
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +41 -3
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/AdConfiguration.js +2 -0
- package/lib/commonjs/models/AdConfiguration.js.map +1 -0
- package/lib/commonjs/models/TrackPurchaseParameters.js +2 -0
- package/lib/commonjs/models/TrackPurchaseParameters.js.map +1 -0
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/FireworkSDK.js +9 -0
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/components/VideoFeed.js +42 -5
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/AdConfiguration.js +2 -0
- package/lib/module/models/AdConfiguration.js.map +1 -0
- package/lib/module/models/TrackPurchaseParameters.js +2 -0
- package/lib/module/models/TrackPurchaseParameters.js.map +1 -0
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/typescript/FireworkSDK.d.ts +6 -0
- package/lib/typescript/components/VideoFeed.d.ts +6 -0
- package/lib/typescript/index.d.ts +4 -1
- package/lib/typescript/models/AdConfiguration.d.ts +22 -0
- package/lib/typescript/models/TrackPurchaseParameters.d.ts +26 -0
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +4 -0
- package/lib/typescript/modules/FireworkSDKModule.d.ts +2 -0
- package/package.json +1 -1
- package/react-native-firework-sdk.podspec +1 -1
- package/src/FireworkSDK.ts +9 -0
- package/src/components/VideoFeed.tsx +35 -1
- package/src/index.tsx +6 -0
- package/src/models/AdConfiguration.ts +23 -0
- package/src/models/TrackPurchaseParameters.ts +24 -0
- package/src/models/VideoFeedConfiguration.ts +4 -0
- package/src/modules/FireworkSDKModule.ts +2 -0
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// Created by Jeff on 2021/12/21.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import FireworkVideo
|
|
9
|
+
import Foundation
|
|
10
10
|
|
|
11
11
|
extension FireworkVideoSDKError {
|
|
12
12
|
var jsErrorName: String {
|
|
@@ -25,13 +25,17 @@ extension FireworkVideoSDKError {
|
|
|
25
25
|
|
|
26
26
|
extension VideoPlaybackDetails {
|
|
27
27
|
var jsObject: [String: Any?] {
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
[
|
|
29
|
+
"videoId": videoID,
|
|
30
|
+
"duration": duration,
|
|
31
|
+
"caption": caption,
|
|
32
|
+
"badge": badge,
|
|
33
|
+
"playerSize": [
|
|
34
|
+
"width": playerSize.width,
|
|
35
|
+
"height": playerSize.height
|
|
36
|
+
],
|
|
37
|
+
"hasCTA": hasCTA
|
|
38
|
+
]
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -40,9 +44,15 @@ extension VideoFeedError {
|
|
|
40
44
|
var error: [String: String] = [:]
|
|
41
45
|
switch self {
|
|
42
46
|
case .contentSourceError(let sourceError):
|
|
43
|
-
error = [
|
|
47
|
+
error = [
|
|
48
|
+
"name": "contentSourceError",
|
|
49
|
+
"reason": sourceError.failureReason ?? "Content source error"
|
|
50
|
+
]
|
|
44
51
|
case .videoShareError(let shareError):
|
|
45
|
-
error = [
|
|
52
|
+
error = [
|
|
53
|
+
"name": "videoShareError",
|
|
54
|
+
"reason": shareError.failureReason ?? "Video share error"
|
|
55
|
+
]
|
|
46
56
|
case .unknownError(let unknownError):
|
|
47
57
|
error = ["name": "unknownError", "reason": unknownError.localizedDescription]
|
|
48
58
|
default:
|
|
@@ -58,27 +68,27 @@ extension FeedEventDetails {
|
|
|
58
68
|
var result: [String: Any] = [
|
|
59
69
|
"index": index,
|
|
60
70
|
"id": id,
|
|
61
|
-
"duration": duration
|
|
71
|
+
"duration": duration
|
|
62
72
|
]
|
|
63
73
|
if let title = caption {
|
|
64
74
|
result["title"] = title
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
var sourceStr: String = ""
|
|
68
|
-
switch
|
|
78
|
+
switch source {
|
|
69
79
|
case .discover:
|
|
70
80
|
sourceStr = "discover"
|
|
71
|
-
case .channel(
|
|
81
|
+
case .channel(let channelID):
|
|
72
82
|
sourceStr = "channel"
|
|
73
83
|
result["channel"] = channelID
|
|
74
|
-
case .channelPlaylist(
|
|
84
|
+
case .channelPlaylist(let channelID, let playlistID):
|
|
75
85
|
sourceStr = "playlist"
|
|
76
86
|
result["channel"] = channelID
|
|
77
87
|
result["playlist"] = playlistID
|
|
78
88
|
case .playlistGroup(groupID: let playlistGroupID):
|
|
79
89
|
sourceStr = "playlistGroup"
|
|
80
90
|
result["playlistGroup"] = playlistGroupID
|
|
81
|
-
case .dynamicContent(
|
|
91
|
+
case .dynamicContent(let channelID, let parameters):
|
|
82
92
|
sourceStr = "dynamicContent"
|
|
83
93
|
result["channel"] = channelID
|
|
84
94
|
result["dynamicContentParameters"] = parameters
|
|
@@ -86,7 +96,7 @@ extension FeedEventDetails {
|
|
|
86
96
|
break
|
|
87
97
|
}
|
|
88
98
|
|
|
89
|
-
result["source"] = sourceStr
|
|
99
|
+
result["source"] = sourceStr
|
|
90
100
|
|
|
91
101
|
return result
|
|
92
102
|
}
|
|
@@ -100,9 +110,11 @@ extension LiveStreamEventDetails {
|
|
|
100
110
|
|
|
101
111
|
extension LiveStreamMessageDetails {
|
|
102
112
|
var jsObject: [String: Any] {
|
|
103
|
-
return [
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
return [
|
|
114
|
+
"messageId": messageID,
|
|
115
|
+
"username": username,
|
|
116
|
+
"text": text
|
|
117
|
+
]
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
120
|
|
|
@@ -111,9 +123,15 @@ extension StoryBlockError {
|
|
|
111
123
|
var error: [String: String] = [:]
|
|
112
124
|
switch self {
|
|
113
125
|
case .contentSourceError(let sourceError):
|
|
114
|
-
error = [
|
|
126
|
+
error = [
|
|
127
|
+
"name": "contentSourceError",
|
|
128
|
+
"reason": sourceError.failureReason ?? "Content source error"
|
|
129
|
+
]
|
|
115
130
|
case .videoShareError(let shareError):
|
|
116
|
-
error = [
|
|
131
|
+
error = [
|
|
132
|
+
"name": "videoShareError",
|
|
133
|
+
"reason": shareError.failureReason ?? "Video share error"
|
|
134
|
+
]
|
|
117
135
|
case .unknownError(underlyingError: let unknownError):
|
|
118
136
|
error = ["name": "unknownError", "reason": unknownError.localizedDescription]
|
|
119
137
|
default:
|
|
@@ -5,18 +5,19 @@
|
|
|
5
5
|
// Created by Jeff on 2021/12/20.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
+
import FireworkVideo
|
|
8
9
|
import Foundation
|
|
9
10
|
import UIKit
|
|
10
|
-
import FireworkVideo
|
|
11
11
|
|
|
12
12
|
extension RCTConvert {
|
|
13
|
-
static func videoPlayerContentConfiguration(_ config: [String: AnyObject])
|
|
13
|
+
static func videoPlayerContentConfiguration(_ config: [String: AnyObject])
|
|
14
|
+
-> VideoPlayerContentConfiguration {
|
|
14
15
|
var finalConfig = VideoPlayerContentConfiguration()
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
if let style = videoPlayerStyle(config["playerStyle"] as? String) {
|
|
17
18
|
finalConfig.playerStyle = style
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
|
|
20
21
|
if let action = videoCompleteAction(config["videoCompleteAction"] as? String) {
|
|
21
22
|
finalConfig.videoCompleteAction = action
|
|
22
23
|
}
|
|
@@ -38,18 +39,20 @@ extension RCTConvert {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
if let launchBehaviorString = config["launchBehavior"] as? String,
|
|
41
|
-
|
|
42
|
+
let launchBehavior = VideoPlayerConfiguration.VideoLaunchBehavior(
|
|
43
|
+
rawValue: launchBehaviorString) {
|
|
42
44
|
finalConfig.onFirstLaunch = launchBehavior.behavior()
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
if let showBranding = config["showBranding"] as? Bool {
|
|
46
48
|
finalConfig.videoDetail.fireworkAttribution.isHidden = !showBranding
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
|
|
49
51
|
return finalConfig
|
|
50
52
|
}
|
|
51
|
-
|
|
52
|
-
static func videoPlayerStyle(_ style: String?) -> VideoPlayerContentConfiguration
|
|
53
|
+
|
|
54
|
+
static func videoPlayerStyle(_ style: String?) -> VideoPlayerContentConfiguration
|
|
55
|
+
.VideoPlayerStyle? {
|
|
53
56
|
guard let rStyle = style else {
|
|
54
57
|
return nil
|
|
55
58
|
}
|
|
@@ -59,8 +62,9 @@ extension RCTConvert {
|
|
|
59
62
|
return .fullBleed
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
|
-
|
|
63
|
-
static func videoCompleteAction(_ action: String?) -> VideoPlayerContentConfiguration
|
|
65
|
+
|
|
66
|
+
static func videoCompleteAction(_ action: String?) -> VideoPlayerContentConfiguration
|
|
67
|
+
.VideoCompleteAction? {
|
|
64
68
|
guard let action = action else {
|
|
65
69
|
return nil
|
|
66
70
|
}
|
|
@@ -70,7 +74,7 @@ extension RCTConvert {
|
|
|
70
74
|
return .advanceToNext
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
|
-
|
|
77
|
+
|
|
74
78
|
static func ctaButtonStyle(_ style: [String: AnyObject]?) -> ButtonContentConfiguration? {
|
|
75
79
|
guard let rStyle = style else {
|
|
76
80
|
return nil
|
|
@@ -85,27 +89,49 @@ extension RCTConvert {
|
|
|
85
89
|
if let fontSize = rStyle["fontSize"] as? Double {
|
|
86
90
|
btnContentConfig.font = UIFont.systemFont(ofSize: fontSize)
|
|
87
91
|
}
|
|
88
|
-
|
|
92
|
+
|
|
89
93
|
return btnContentConfig
|
|
90
94
|
}
|
|
91
|
-
|
|
95
|
+
|
|
92
96
|
static func adBadgeConfiguration(_ config: [String: AnyObject]?) -> AdBadgeConfiguration? {
|
|
93
97
|
guard let rConfig = config else {
|
|
94
98
|
return nil
|
|
95
99
|
}
|
|
96
|
-
|
|
100
|
+
|
|
97
101
|
let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
|
|
98
102
|
guard let rJsonData = jsonData else {
|
|
99
103
|
return nil
|
|
100
104
|
}
|
|
101
|
-
|
|
105
|
+
|
|
102
106
|
var result: AdBadgeConfiguration?
|
|
103
107
|
do {
|
|
104
108
|
result = try JSONDecoder().decode(AdBadgeConfiguration.self, from: rJsonData)
|
|
105
109
|
} catch let error {
|
|
106
110
|
print(error.localizedDescription)
|
|
107
111
|
}
|
|
108
|
-
|
|
112
|
+
|
|
113
|
+
return result
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static func trackPurchaseParameters(_ parameters: [String: AnyObject]?)
|
|
117
|
+
-> TrackPurchaseParameters? {
|
|
118
|
+
guard let rParameters = parameters else {
|
|
119
|
+
return nil
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let jsonData = try? JSONSerialization.data(
|
|
123
|
+
withJSONObject: rParameters, options: .prettyPrinted)
|
|
124
|
+
guard let rJsonData = jsonData else {
|
|
125
|
+
return nil
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var result: TrackPurchaseParameters?
|
|
129
|
+
do {
|
|
130
|
+
result = try JSONDecoder().decode(TrackPurchaseParameters.self, from: rJsonData)
|
|
131
|
+
} catch let error {
|
|
132
|
+
print(error.localizedDescription)
|
|
133
|
+
}
|
|
134
|
+
|
|
109
135
|
return result
|
|
110
136
|
}
|
|
111
137
|
}
|
|
@@ -12,27 +12,28 @@ extension RCTConvert {
|
|
|
12
12
|
guard let rRawProducts = rawProducts else {
|
|
13
13
|
return nil
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
var products = [Product]()
|
|
17
17
|
for rawProduct in rRawProducts {
|
|
18
|
-
let product = buildProduct(rawProduct as? [String
|
|
18
|
+
let product = buildProduct(rawProduct as? [String: Any])
|
|
19
19
|
if let rProduct = product {
|
|
20
20
|
products.append(rProduct)
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
return products
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
static func buildProduct(_ product: [String: Any]?) -> Product? {
|
|
27
27
|
guard let rProduct = product else {
|
|
28
28
|
return nil
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
let jsonData = try? JSONSerialization.data(
|
|
30
|
+
|
|
31
|
+
let jsonData = try? JSONSerialization.data(
|
|
32
|
+
withJSONObject: rProduct, options: .prettyPrinted)
|
|
32
33
|
guard let rJsonData = jsonData else {
|
|
33
34
|
return nil
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
|
|
36
37
|
var result: Product?
|
|
37
38
|
do {
|
|
38
39
|
result = try JSONDecoder().decode(Product.self, from: rJsonData)
|
|
@@ -41,24 +42,25 @@ extension RCTConvert {
|
|
|
41
42
|
}
|
|
42
43
|
return result
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
static func buildProductInfoViewConfiguration(_ config: [String: Any]?)
|
|
45
|
+
|
|
46
|
+
static func buildProductInfoViewConfiguration(_ config: [String: Any]?)
|
|
47
|
+
-> ProductInfoViewConfiguration? {
|
|
46
48
|
guard let rConfig = config else {
|
|
47
49
|
return nil
|
|
48
50
|
}
|
|
49
|
-
|
|
51
|
+
|
|
50
52
|
let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
|
|
51
53
|
guard let rJsonData = jsonData else {
|
|
52
54
|
return nil
|
|
53
55
|
}
|
|
54
|
-
|
|
56
|
+
|
|
55
57
|
var result: ProductInfoViewConfiguration?
|
|
56
58
|
do {
|
|
57
59
|
result = try JSONDecoder().decode(ProductInfoViewConfiguration.self, from: rJsonData)
|
|
58
60
|
} catch let error {
|
|
59
61
|
print(error.localizedDescription)
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
|
|
62
64
|
return result
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -9,16 +9,18 @@ import Foundation
|
|
|
9
9
|
|
|
10
10
|
extension StoryBlockSourceType {
|
|
11
11
|
static var sourceTypeMapper: [String: StoryBlockSourceType] {
|
|
12
|
-
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
[
|
|
13
|
+
"discover": .discover,
|
|
14
|
+
"channel": .channel,
|
|
15
|
+
"playlist": .playlist,
|
|
16
|
+
"dynamicContent": .dynamicContent
|
|
17
|
+
]
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
@objc
|
|
20
|
-
|
|
21
|
-
static func storyBlockSourceType(_ type: String?) -> StoryBlockSourceType {
|
|
22
|
+
extension RCTConvert {
|
|
23
|
+
public static func storyBlockSourceType(_ type: String?) -> StoryBlockSourceType {
|
|
22
24
|
guard let rType = type else {
|
|
23
25
|
return .discover
|
|
24
26
|
}
|
|
@@ -9,63 +9,82 @@ import Foundation
|
|
|
9
9
|
|
|
10
10
|
extension VideFeedSourceType {
|
|
11
11
|
static var sourceTypeMapper: [String: VideFeedSourceType] {
|
|
12
|
-
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
[
|
|
13
|
+
"discover": .discover,
|
|
14
|
+
"channel": .channel,
|
|
15
|
+
"playlist": .playlist,
|
|
16
|
+
"playlistGroup": .playlistGroup,
|
|
17
|
+
"dynamicContent": .dynamicContent
|
|
18
|
+
]
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
extension VideoFeedMode {
|
|
21
23
|
static var feedModeMapper: [String: VideoFeedMode] {
|
|
22
|
-
[
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
[
|
|
25
|
+
"row": .row,
|
|
26
|
+
"column": .column,
|
|
27
|
+
"grid": .grid
|
|
28
|
+
]
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
@objc
|
|
29
|
-
|
|
30
|
-
static func videoFeedSourceType(_ type: String?) -> VideFeedSourceType {
|
|
33
|
+
extension RCTConvert {
|
|
34
|
+
public static func videoFeedSourceType(_ type: String?) -> VideFeedSourceType {
|
|
31
35
|
guard let rType = type else {
|
|
32
36
|
return .discover
|
|
33
37
|
}
|
|
34
|
-
|
|
38
|
+
|
|
35
39
|
return VideFeedSourceType.sourceTypeMapper[rType] ?? .discover
|
|
36
40
|
}
|
|
37
|
-
|
|
38
|
-
static func videoFeedMode(_ type: String?) -> VideoFeedMode {
|
|
41
|
+
|
|
42
|
+
public static func videoFeedMode(_ type: String?) -> VideoFeedMode {
|
|
39
43
|
guard let rType = type else {
|
|
40
44
|
return .row
|
|
41
45
|
}
|
|
42
|
-
|
|
46
|
+
|
|
43
47
|
return VideoFeedMode.feedModeMapper[rType] ?? .row
|
|
44
48
|
}
|
|
45
|
-
|
|
46
|
-
static func videoFeedConfiguration(_ config: [String: AnyObject]?)
|
|
49
|
+
|
|
50
|
+
public static func videoFeedConfiguration(_ config: [String: AnyObject]?)
|
|
51
|
+
-> VideoFeedConfiguration? {
|
|
47
52
|
guard let rConfig = config else {
|
|
48
53
|
return nil
|
|
49
54
|
}
|
|
50
|
-
|
|
55
|
+
|
|
51
56
|
let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
|
|
52
57
|
guard let rJsonData = jsonData else {
|
|
53
58
|
return nil
|
|
54
59
|
}
|
|
55
|
-
|
|
60
|
+
|
|
56
61
|
return try? JSONDecoder().decode(VideoFeedConfiguration.self, from: rJsonData)
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
static func videoPlayerConfiguration(_ config: [String: AnyObject]?)
|
|
63
|
+
|
|
64
|
+
public static func videoPlayerConfiguration(_ config: [String: AnyObject]?)
|
|
65
|
+
-> VideoPlayerConfiguration? {
|
|
60
66
|
guard let rConfig = config else {
|
|
61
67
|
return nil
|
|
62
68
|
}
|
|
63
|
-
|
|
69
|
+
|
|
64
70
|
let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
|
|
65
71
|
guard let rJsonData = jsonData else {
|
|
66
72
|
return nil
|
|
67
73
|
}
|
|
68
|
-
|
|
74
|
+
|
|
69
75
|
return try? JSONDecoder().decode(VideoPlayerConfiguration.self, from: rJsonData)
|
|
70
76
|
}
|
|
77
|
+
|
|
78
|
+
public static func adConfiguration(_ config: [String: AnyObject]?) -> AdConfiguration? {
|
|
79
|
+
guard let rConfig = config else {
|
|
80
|
+
return nil
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
|
|
84
|
+
guard let rJsonData = jsonData else {
|
|
85
|
+
return nil
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return try? JSONDecoder().decode(AdConfiguration.self, from: rJsonData)
|
|
89
|
+
}
|
|
71
90
|
}
|
|
@@ -15,12 +15,13 @@ class FWNavigatorContainerViewController: UIViewController {
|
|
|
15
15
|
super.viewDidLoad()
|
|
16
16
|
loadContent()
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
private func loadContent() {
|
|
20
|
-
let rctRootView = RCTRootView.init(
|
|
20
|
+
let rctRootView = RCTRootView.init(
|
|
21
|
+
bridge: RCTBridge.current(), moduleName: moduleName, initialProperties: properties)
|
|
21
22
|
view.addSubview(rctRootView)
|
|
22
23
|
rctRootView.translatesAutoresizingMaskIntoConstraints = false
|
|
23
|
-
|
|
24
|
+
|
|
24
25
|
NSLayoutConstraint.activate([
|
|
25
26
|
rctRootView.leftAnchor.constraint(equalTo: view.leftAnchor),
|
|
26
27
|
rctRootView.topAnchor.constraint(equalTo: view.topAnchor),
|
|
@@ -10,19 +10,28 @@ import FireworkVideo
|
|
|
10
10
|
@objc(FWNavigatorModule)
|
|
11
11
|
class FWNavigatorModule: RCTEventEmitter, FWNavigator {
|
|
12
12
|
override func supportedEvents() -> [String]! {
|
|
13
|
-
return [FWEventName.
|
|
13
|
+
return [FWEventName.logMessage.rawValue]
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
override class func requiresMainQueueSetup() -> Bool {
|
|
17
17
|
return true
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// swiftlint:disable function_body_length
|
|
21
|
+
|
|
20
22
|
@objc(pushNativeContainer:resolver:rejecter:)
|
|
21
|
-
func pushNativeContainer(
|
|
23
|
+
func pushNativeContainer(
|
|
24
|
+
_ props: NSDictionary?, resolver: @escaping RCTPromiseResolveBlock,
|
|
25
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
26
|
+
) {
|
|
22
27
|
#if DEBUG
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
let formatter = DateFormatter()
|
|
29
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
30
|
+
sendEvent(
|
|
31
|
+
withName: FWEventName.logMessage.rawValue,
|
|
32
|
+
body: [
|
|
33
|
+
"message": "[iOS] Enter pushNativeContainer \(formatter.string(from: Date()))"
|
|
34
|
+
])
|
|
26
35
|
#endif
|
|
27
36
|
|
|
28
37
|
DispatchQueue.main.async {
|
|
@@ -42,31 +51,52 @@ class FWNavigatorModule: RCTEventEmitter, FWNavigator {
|
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
#if DEBUG
|
|
45
|
-
|
|
54
|
+
self.sendEvent(
|
|
55
|
+
withName: FWEventName.logMessage.rawValue,
|
|
56
|
+
body: [
|
|
57
|
+
"message":
|
|
58
|
+
"[iOS] Before creating containerViewController \(formatter.string(from: Date()))"
|
|
59
|
+
])
|
|
46
60
|
#endif
|
|
47
61
|
|
|
48
62
|
let containerViewController = FWNavigatorContainerViewController()
|
|
49
63
|
|
|
50
64
|
#if DEBUG
|
|
51
|
-
|
|
65
|
+
self.sendEvent(
|
|
66
|
+
withName: FWEventName.logMessage.rawValue,
|
|
67
|
+
body: [
|
|
68
|
+
"message":
|
|
69
|
+
"[iOS] After creating containerViewController \(formatter.string(from: Date()))"
|
|
70
|
+
])
|
|
52
71
|
#endif
|
|
53
72
|
|
|
54
73
|
containerViewController.moduleName = appComponentName
|
|
55
74
|
containerViewController.properties = props
|
|
56
75
|
containerViewController.modalPresentationStyle = .fullScreen
|
|
57
76
|
if presentedVC.modalPresentationStyle == .custom,
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
let presentingVC = presentedVC.presentingViewController,
|
|
78
|
+
presentingVC is FireworkVideo.PlayerViewController
|
|
79
|
+
{
|
|
60
80
|
containerViewController.modalPresentationStyle = .overFullScreen
|
|
61
81
|
}
|
|
62
82
|
|
|
63
83
|
#if DEBUG
|
|
64
|
-
|
|
84
|
+
self.sendEvent(
|
|
85
|
+
withName: FWEventName.logMessage.rawValue,
|
|
86
|
+
body: [
|
|
87
|
+
"message":
|
|
88
|
+
"[iOS] Present containerViewController \(formatter.string(from: Date()))"
|
|
89
|
+
])
|
|
65
90
|
#endif
|
|
66
91
|
|
|
67
92
|
presentedVC.present(containerViewController, animated: true) {
|
|
68
93
|
#if DEBUG
|
|
69
|
-
|
|
94
|
+
self.sendEvent(
|
|
95
|
+
withName: FWEventName.logMessage.rawValue,
|
|
96
|
+
body: [
|
|
97
|
+
"message":
|
|
98
|
+
"[iOS] Finish presenting containerViewController \(formatter.string(from: Date()))"
|
|
99
|
+
])
|
|
70
100
|
#endif
|
|
71
101
|
|
|
72
102
|
resolver(true)
|
|
@@ -74,10 +104,15 @@ class FWNavigatorModule: RCTEventEmitter, FWNavigator {
|
|
|
74
104
|
}
|
|
75
105
|
}
|
|
76
106
|
|
|
107
|
+
// swiftlint:enable function_body_length
|
|
108
|
+
|
|
77
109
|
@objc(popNativeContainer:rejecter:)
|
|
78
|
-
func popNativeContainer(
|
|
110
|
+
func popNativeContainer(
|
|
111
|
+
_ resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock
|
|
112
|
+
) {
|
|
79
113
|
DispatchQueue.main.async {
|
|
80
|
-
if let navigatorContainerVC = RCTPresentedViewController()
|
|
114
|
+
if let navigatorContainerVC = RCTPresentedViewController()
|
|
115
|
+
as? FWNavigatorContainerViewController,
|
|
81
116
|
navigatorContainerVC.presentingViewController != nil {
|
|
82
117
|
navigatorContainerVC.dismiss(animated: true) {
|
|
83
118
|
resolver(true)
|
|
@@ -87,9 +122,9 @@ class FWNavigatorModule: RCTEventEmitter, FWNavigator {
|
|
|
87
122
|
gCartViewController = nil
|
|
88
123
|
resolver(true)
|
|
89
124
|
} else if let presentedVC = RCTPresentedViewController(),
|
|
90
|
-
|
|
125
|
+
let presentingVC = presentedVC.presentingViewController {
|
|
91
126
|
if presentedVC.modalPresentationStyle == .custom,
|
|
92
|
-
|
|
127
|
+
presentingVC is FireworkVideo.PlayerViewController {
|
|
93
128
|
// For consistency with Android SDK behavior
|
|
94
129
|
presentedVC.dismiss(animated: false) {
|
|
95
130
|
DispatchQueue.main.async {
|
|
@@ -110,12 +145,14 @@ class FWNavigatorModule: RCTEventEmitter, FWNavigator {
|
|
|
110
145
|
}
|
|
111
146
|
|
|
112
147
|
@objc(canPopNativeContainer:rejecter:)
|
|
113
|
-
func canPopNativeContainer(
|
|
148
|
+
func canPopNativeContainer(
|
|
149
|
+
_ resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock
|
|
150
|
+
) {
|
|
114
151
|
DispatchQueue.main.async {
|
|
115
152
|
if let presentedVC = RCTPresentedViewController(),
|
|
116
153
|
presentedVC.presentingViewController != nil {
|
|
117
154
|
resolver(true)
|
|
118
|
-
} else if
|
|
155
|
+
} else if gCartViewController != nil {
|
|
119
156
|
resolver(true)
|
|
120
157
|
} else {
|
|
121
158
|
resolver(false)
|
|
@@ -123,4 +160,3 @@ class FWNavigatorModule: RCTEventEmitter, FWNavigator {
|
|
|
123
160
|
}
|
|
124
161
|
}
|
|
125
162
|
}
|
|
126
|
-
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
|
|
10
10
|
protocol FWNavigator {
|
|
11
|
-
func pushNativeContainer(
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
func pushNativeContainer(
|
|
12
|
+
_ props: NSDictionary?, resolver: @escaping RCTPromiseResolveBlock,
|
|
13
|
+
rejecter: @escaping RCTPromiseRejectBlock)
|
|
14
|
+
func popNativeContainer(
|
|
15
|
+
_ resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock)
|
|
16
|
+
func canPopNativeContainer(
|
|
17
|
+
_ resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock)
|
|
14
18
|
}
|
|
@@ -11,8 +11,9 @@ struct AdBadgeConfiguration: Codable {
|
|
|
11
11
|
var badgeTextType: BadgeTextType = .ad
|
|
12
12
|
var backgroundColor: String?
|
|
13
13
|
var textColor: String?
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
enum BadgeTextType: String, Codable {
|
|
16
|
+
// swiftlint:disable:next identifier_name
|
|
16
17
|
case ad, sponsored
|
|
17
18
|
}
|
|
18
19
|
}
|