react-native-firework-sdk 1.9.0-beta.3 → 1.9.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 +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWLanguageUtil.kt +47 -14
- package/ios/Components/StoryBlock.swift +28 -1
- package/ios/Components/StoryBlockManager.m +32 -0
- package/ios/Components/VideoFeed.swift +1 -24
- package/ios/Components/VideoFeedManager.m +11 -6
- package/ios/FireworkSdk-Bridging-Header.h +0 -6
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +4 -0
- package/ios/Models/NativeToRN/FireworkEventName.swift +2 -1
- package/ios/Models/RNToNative/RCTConvert+Shopping.swift +21 -0
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +27 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +4 -4
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +4 -4
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +13 -0
- package/ios/Modules/Shopping/ShoppingCTAResult.swift +16 -0
- package/ios/Modules/Shopping/ShoppingModule.m +2 -1
- package/ios/Modules/Shopping/ShoppingModule.swift +103 -30
- package/ios/Support/MultiHostStreaming/FWMultiHostStreaming.podspec +24 -0
- package/ios/Support/MultiHostStreaming/src/MultiHostStreamingSDK.swift +17 -0
- package/ios/Utils/AppLanguage/FWAppLanguageManager.swift +23 -2
- package/ios/Utils/AppLanguage/FWLanguageUtil.swift +5 -1
- package/ios/Utils/AppLanguage/UIImageView+FWSwizzle.swift +3 -3
- package/ios/Utils/FWSwizzleLoader.m +5 -0
- package/ios/scripts/react_native_firework_sdk_pods.rb +31 -0
- package/lib/commonjs/FWNavigator.js +2 -2
- package/lib/commonjs/FWNavigator.js.map +1 -1
- package/lib/commonjs/FireworkSDK.js +14 -1
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +71 -22
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +156 -106
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +29 -15
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +1 -0
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/ShoppingCTAResult.js +2 -0
- package/lib/commonjs/models/ShoppingCTAResult.js.map +1 -0
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FWNavigator.js +5 -2
- package/lib/module/FWNavigator.js.map +1 -1
- package/lib/module/FireworkSDK.js +14 -1
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +70 -23
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +146 -103
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +36 -12
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +1 -0
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/ShoppingCTAResult.js +2 -0
- package/lib/module/models/ShoppingCTAResult.js.map +1 -0
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FWNavigator.d.ts +5 -2
- package/lib/typescript/FireworkSDK.d.ts +14 -3
- package/lib/typescript/VideoShopping.d.ts +26 -5
- package/lib/typescript/components/StoryBlock.d.ts +21 -11
- package/lib/typescript/components/VideoFeed.d.ts +20 -4
- package/lib/typescript/index.d.ts +6 -5
- package/lib/typescript/models/AddToCartResult.d.ts +4 -0
- package/lib/typescript/models/FWEventName.d.ts +1 -0
- package/lib/typescript/models/FWEvents.d.ts +27 -0
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +35 -0
- package/lib/typescript/models/ShoppingCTAResult.d.ts +11 -0
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +2 -1
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +2 -0
- package/lib/typescript/modules/FireworkSDKModule.d.ts +1 -2
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -0
- package/package.json +5 -4
- package/react-native-firework-sdk.podspec +14 -9
- package/src/FWNavigator.ts +5 -2
- package/src/FireworkSDK.ts +15 -4
- package/src/VideoShopping.ts +107 -32
- package/src/components/StoryBlock.tsx +158 -84
- package/src/components/VideoFeed.tsx +28 -11
- package/src/index.ts +15 -1
- package/src/models/AddToCartResult.ts +4 -0
- package/src/models/FWEventName.ts +1 -0
- package/src/models/FWEvents.ts +28 -0
- package/src/models/ProductInfoViewConfiguration.ts +37 -0
- package/src/models/ShoppingCTAResult.ts +11 -0
- package/src/models/VideoFeedConfiguration.ts +2 -1
- package/src/models/VideoPlayerConfiguration.ts +2 -0
- package/src/modules/FireworkSDKModule.ts +1 -2
- package/src/modules/ShoppingModule.ts +6 -1
- package/ios/scripts/firework_sdk_pods.rb +0 -3
|
@@ -25,6 +25,10 @@ export interface VideoPlaybackEvent {
|
|
|
25
25
|
export interface VideoFeedClickEvent {
|
|
26
26
|
info: FeedItemDetails;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated The interface will be removed since RN SDK V2.1.
|
|
30
|
+
* Use {@link ShoppingCTAEvent} instead.
|
|
31
|
+
*/
|
|
28
32
|
export interface AddToCartEvent {
|
|
29
33
|
/**
|
|
30
34
|
* A unique identifier of the product.
|
|
@@ -35,6 +39,20 @@ export interface AddToCartEvent {
|
|
|
35
39
|
*/
|
|
36
40
|
unitId: string;
|
|
37
41
|
}
|
|
42
|
+
export interface ShoppingCTAEvent {
|
|
43
|
+
/**
|
|
44
|
+
* The url for the product unit
|
|
45
|
+
*/
|
|
46
|
+
url: string;
|
|
47
|
+
/**
|
|
48
|
+
* A unique identifier of the product.
|
|
49
|
+
*/
|
|
50
|
+
productId: string;
|
|
51
|
+
/**
|
|
52
|
+
* A unique identifier of the product unit.
|
|
53
|
+
*/
|
|
54
|
+
unitId: string;
|
|
55
|
+
}
|
|
38
56
|
export interface UpdateProductDetailsEvent {
|
|
39
57
|
/**
|
|
40
58
|
* A unique identifier list of the products.
|
|
@@ -57,7 +75,16 @@ export interface LiveStreamChatEvent {
|
|
|
57
75
|
liveStream: LiveStreamEventDetails;
|
|
58
76
|
}
|
|
59
77
|
export interface CustomClickLinkButtonEvent {
|
|
78
|
+
/**
|
|
79
|
+
* The url for the product unit
|
|
80
|
+
*/
|
|
60
81
|
url: string;
|
|
82
|
+
/**
|
|
83
|
+
* A unique identifier of the product.
|
|
84
|
+
*/
|
|
61
85
|
productId: string;
|
|
86
|
+
/**
|
|
87
|
+
* A unique identifier of the product unit.
|
|
88
|
+
*/
|
|
62
89
|
unitId: string;
|
|
63
90
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type IOSFontInfo from './IOSFontInfo';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated The interface will be removed since RN SDK V2.1.
|
|
4
|
+
* Use {@link ShoppingCTAButtonConfiguration} instead.
|
|
5
|
+
*/
|
|
2
6
|
export interface AddToCartButtonConfiguration {
|
|
3
7
|
/**
|
|
4
8
|
* The background color of "Add to cart" button.
|
|
@@ -19,14 +23,45 @@ export interface AddToCartButtonConfiguration {
|
|
|
19
23
|
*/
|
|
20
24
|
iOSFontInfo?: IOSFontInfo;
|
|
21
25
|
}
|
|
26
|
+
export type ShoppingCTAButtonText = 'addToCart' | 'shopNow';
|
|
27
|
+
export interface ShoppingCTAButtonConfiguration {
|
|
28
|
+
/**
|
|
29
|
+
* The text of shopping CTA button.
|
|
30
|
+
*/
|
|
31
|
+
text?: ShoppingCTAButtonText;
|
|
32
|
+
/**
|
|
33
|
+
* The background color of CTA button.
|
|
34
|
+
*/
|
|
35
|
+
backgroundColor?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The text color of CTA button.
|
|
38
|
+
*/
|
|
39
|
+
textColor?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The font size of CTA button.
|
|
42
|
+
*/
|
|
43
|
+
fontSize?: number;
|
|
44
|
+
/**
|
|
45
|
+
* The iOS font info of "Add to cart" button.
|
|
46
|
+
* The property is ignored when fontSize is not set.
|
|
47
|
+
*/
|
|
48
|
+
iOSFontInfo?: IOSFontInfo;
|
|
49
|
+
}
|
|
22
50
|
export interface LinkButtonConfiguration {
|
|
23
51
|
isHidden?: boolean;
|
|
24
52
|
}
|
|
25
53
|
export default interface ProductInfoViewConfiguration {
|
|
26
54
|
/**
|
|
27
55
|
* Configuration of "Add to cart" button. Only supported on iOS.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated The property will be removed since RN SDK V2.1.
|
|
58
|
+
* Use {@link ctaButton} instead.
|
|
28
59
|
*/
|
|
29
60
|
addToCartButton?: AddToCartButtonConfiguration;
|
|
61
|
+
/**
|
|
62
|
+
* Configuration of shopping CTA button. Only supported on iOS.
|
|
63
|
+
*/
|
|
64
|
+
ctaButton?: ShoppingCTAButtonConfiguration;
|
|
30
65
|
/**
|
|
31
66
|
* Configuration of link button next to "Add to cart" button. Only supported on iOS.
|
|
32
67
|
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default interface ShoppingCTAResult {
|
|
2
|
+
/**
|
|
3
|
+
* The result of shopping CTA button
|
|
4
|
+
*/
|
|
5
|
+
res: 'success' | 'fail';
|
|
6
|
+
/**
|
|
7
|
+
* We will show a toast to display the tips.
|
|
8
|
+
* If the property is undefined or empty string, we don't show a toast.
|
|
9
|
+
*/
|
|
10
|
+
tips?: string;
|
|
11
|
+
}
|
|
@@ -84,7 +84,8 @@ export default interface VideoFeedConfiguration {
|
|
|
84
84
|
/**
|
|
85
85
|
* Please use the enablePictureInPicture in IVideoFeedProps. Only supported on iOS.
|
|
86
86
|
*
|
|
87
|
-
* @deprecated The property will be deprecated since RN SDK V2.
|
|
87
|
+
* @deprecated The property will be deprecated since RN SDK V2.0.
|
|
88
|
+
* Use {@link IVideoFeedProps.enablePictureInPicture} of {@link IVideoFeedProps} instead.
|
|
88
89
|
*/
|
|
89
90
|
enablePictureInPicture?: boolean;
|
|
90
91
|
}
|
|
@@ -12,8 +12,7 @@ interface IFireworkSDKModule extends NativeModule {
|
|
|
12
12
|
setAdBadgeConfiguration(config?: AdBadgeConfiguration): Promise<any>;
|
|
13
13
|
setAppComponentName(name?: string): Promise<any>;
|
|
14
14
|
trackPurchase(parameters: TrackPurchaseParameters): void;
|
|
15
|
-
changeAppLanguage(language
|
|
16
|
-
restart(): Promise<void>;
|
|
15
|
+
changeAppLanguage(language?: string | null): Promise<boolean>;
|
|
17
16
|
}
|
|
18
17
|
declare const FireworkSDKModuleEventEmitter: NativeEventEmitter;
|
|
19
18
|
export { FireworkSDKModuleEventEmitter };
|
|
@@ -2,10 +2,12 @@ import { NativeEventEmitter, NativeModule } from 'react-native';
|
|
|
2
2
|
import type { NewNativeContainerProps } from '../models/NewNativeContainerProps';
|
|
3
3
|
import type Product from '../models/Product';
|
|
4
4
|
import type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';
|
|
5
|
+
import type ShoppingCTAResult from '../models/ShoppingCTAResult';
|
|
5
6
|
interface IShoppingModule extends NativeModule {
|
|
6
7
|
init(): void;
|
|
7
8
|
updateVideoProducts(products: Product[], callbackId: number | string): void;
|
|
8
9
|
updateAddToCartStatus(res: string, tips: string, callbackId: number | string): void;
|
|
10
|
+
updateShoppingCTAResult(result: ShoppingCTAResult, callbackId: number | string): void;
|
|
9
11
|
jumpToCartPage(callbackId: number | string, props: NewNativeContainerProps): void;
|
|
10
12
|
setCartIconVisible(visible: boolean): void;
|
|
11
13
|
setCartItemCount(count: number): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-firework-sdk",
|
|
3
|
-
"version": "1.9.0
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Firework React Native SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"android"
|
|
35
35
|
],
|
|
36
36
|
"repository": "",
|
|
37
|
-
"author": "",
|
|
37
|
+
"author": "Loop Now Technologies, Inc.",
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
39
|
"bugs": {
|
|
40
40
|
"url": "https://github.com/loopsocial/react-native-firework-sdk/issues"
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"react-native": "0.66.4",
|
|
61
61
|
"react-native-builder-bob": "^0.18.0",
|
|
62
62
|
"typedoc": "^0.23.27",
|
|
63
|
-
"typescript": "^4.
|
|
63
|
+
"typescript": "^4.9.5"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"react": "*",
|
|
@@ -101,7 +101,8 @@
|
|
|
101
101
|
},
|
|
102
102
|
"eslintIgnore": [
|
|
103
103
|
"node_modules/",
|
|
104
|
-
"lib/"
|
|
104
|
+
"lib/",
|
|
105
|
+
"docs/"
|
|
105
106
|
],
|
|
106
107
|
"prettier": {
|
|
107
108
|
"quoteProps": "consistent",
|
|
@@ -14,15 +14,20 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
s.source = { git: 'https://github.com/loopsocial/bogano.git', tag: "#{s.version}" }
|
|
15
15
|
|
|
16
16
|
s.swift_version = '5.0'
|
|
17
|
-
# s.header_dir =
|
|
18
|
-
# s.public_header_files =
|
|
17
|
+
# s.header_dir = 'ios'
|
|
18
|
+
# s.public_header_files = 'ios/*.h'
|
|
19
19
|
s.source_files = 'ios/**/*.{h,m,mm,swift}'
|
|
20
|
-
s.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
s.exclude_files = 'ios/Support/**/*.{h,m,mm,swift}'
|
|
21
|
+
s.script_phase = { name: 'Copy module header files', script: '
|
|
22
|
+
module_header_path="${PODS_TARGET_SRCROOT}/ios/react_native_firework_sdk.h"
|
|
23
|
+
target_header_directory="${PODS_ROOT}/Headers/Public/react_native_firework_sdk/"
|
|
24
|
+
echo "module_header_path $module_header_path"
|
|
25
|
+
echo "target_header_directory $target_header_directory"
|
|
26
|
+
if [ -d $target_header_directory ]
|
|
27
|
+
then
|
|
28
|
+
cp -f $module_header_path $target_header_directory
|
|
29
|
+
fi
|
|
30
|
+
', execution_position: :before_compile }
|
|
25
31
|
s.dependency 'React-Core'
|
|
26
|
-
|
|
27
|
-
s.dependency 'FireworkVideo', '1.7.0'
|
|
32
|
+
s.dependency 'FireworkVideo', '1.8.0'
|
|
28
33
|
end
|
package/src/FWNavigator.ts
CHANGED
|
@@ -5,6 +5,9 @@ import FWNavigatorModule, {
|
|
|
5
5
|
} from './modules/FWNavigatorModule';
|
|
6
6
|
import FWLoggerUtil from './utils/FWLoggerUtil';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated The type will be deprecated since RN SDK V2.0.
|
|
10
|
+
*/
|
|
8
11
|
export type FWNativeContainerProps = {
|
|
9
12
|
[key: string]: any;
|
|
10
13
|
};
|
|
@@ -33,7 +36,7 @@ class FWNavigator {
|
|
|
33
36
|
* @param {FWNativeContainerProps} props We will pass the props to your app component.
|
|
34
37
|
* @returns {Promise<boolean>} The result of pushing RN page from native page.
|
|
35
38
|
*
|
|
36
|
-
* @deprecated The
|
|
39
|
+
* @deprecated The method will be deprecated since RN SDK V2.0.
|
|
37
40
|
*/
|
|
38
41
|
public pushNativeContainer(props: FWNativeContainerProps): Promise<boolean> {
|
|
39
42
|
FWLoggerUtil.log(`Enter pushNewNativeContainer`);
|
|
@@ -54,7 +57,7 @@ class FWNavigator {
|
|
|
54
57
|
* @returns {Promise<boolean>} If the result is true,
|
|
55
58
|
* we could call popNativeContainer to pop top-most native container.
|
|
56
59
|
*
|
|
57
|
-
* @deprecated The
|
|
60
|
+
* @deprecated The method will be deprecated since RN SDK V2.0.
|
|
58
61
|
*/
|
|
59
62
|
public canPopNativeContainer(): Promise<boolean> {
|
|
60
63
|
return FWNavigatorModule.canPopNativeContainer();
|
package/src/FireworkSDK.ts
CHANGED
|
@@ -56,10 +56,15 @@ class FireworkSDK {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* The custom CTA link content page route name.
|
|
59
|
+
*
|
|
60
|
+
* @deprecated The get accessor will be deprecated since RN SDK V2.0.
|
|
59
61
|
*/
|
|
60
62
|
public get customCTALinkContentPageRouteName(): string | undefined {
|
|
61
63
|
return this._customCTALinkContentPageRouteName;
|
|
62
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated The set accessor will be deprecated since RN SDK V2.0.
|
|
67
|
+
*/
|
|
63
68
|
public set customCTALinkContentPageRouteName(value: string | undefined) {
|
|
64
69
|
this._customCTALinkContentPageRouteName = value;
|
|
65
70
|
FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');
|
|
@@ -120,20 +125,25 @@ class FireworkSDK {
|
|
|
120
125
|
|
|
121
126
|
/**
|
|
122
127
|
* The app component name.
|
|
128
|
+
*
|
|
129
|
+
* @deprecated The get accessor will be deprecated since RN SDK V2.0.
|
|
123
130
|
*/
|
|
124
131
|
public get appComponentName(): string | undefined {
|
|
125
132
|
return this._appComponentName;
|
|
126
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* @deprecated The set accessor will be deprecated since RN SDK V2.0.
|
|
136
|
+
*/
|
|
127
137
|
public set appComponentName(value: string | undefined) {
|
|
128
138
|
this._appComponentName = value;
|
|
129
139
|
FireworkSDKModule.setAppComponentName(value ?? '');
|
|
130
140
|
}
|
|
131
141
|
private _appComponentName: string | undefined;
|
|
132
142
|
|
|
133
|
-
public get appLanguage(): string | undefined {
|
|
143
|
+
public get appLanguage(): string | undefined | null {
|
|
134
144
|
return this._appLanguage;
|
|
135
145
|
}
|
|
136
|
-
private _appLanguage: string | undefined;
|
|
146
|
+
private _appLanguage: string | undefined | null;
|
|
137
147
|
|
|
138
148
|
/**
|
|
139
149
|
* Defaults to false. You can enable debug logs by setting this property to true.
|
|
@@ -259,10 +269,11 @@ class FireworkSDK {
|
|
|
259
269
|
|
|
260
270
|
/**
|
|
261
271
|
* Change App level language.
|
|
262
|
-
* @param {string} language Such as en, ar and en-US
|
|
272
|
+
* @param {string | undefined | null} language Such as en, ar and en-US
|
|
273
|
+
* If language is null or undefined or empty string, we will use system language.
|
|
263
274
|
* @returns
|
|
264
275
|
*/
|
|
265
|
-
public async changeAppLanguage(language
|
|
276
|
+
public async changeAppLanguage(language?: string | null): Promise<boolean> {
|
|
266
277
|
const result = await FireworkSDKModule.changeAppLanguage(language);
|
|
267
278
|
if (result) {
|
|
268
279
|
const valueHasChanged = this._appLanguage !== language;
|
package/src/VideoShopping.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type AddToCartResult from './models/AddToCartResult';
|
|
|
4
4
|
import type {
|
|
5
5
|
AddToCartEvent,
|
|
6
6
|
CustomClickLinkButtonEvent,
|
|
7
|
+
ShoppingCTAEvent,
|
|
7
8
|
UpdateProductDetailsEvent,
|
|
8
9
|
WillDisplayProductEvent,
|
|
9
10
|
} from './models/FWEvents';
|
|
@@ -15,11 +16,22 @@ import ShoppingModule, {
|
|
|
15
16
|
} from './modules/ShoppingModule';
|
|
16
17
|
import type { NewNativeContainerProps } from './models/NewNativeContainerProps';
|
|
17
18
|
import FWLoggerUtil from './utils/FWLoggerUtil';
|
|
19
|
+
import type ShoppingCTAResult from './models/ShoppingCTAResult';
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated The type will be deprecated since RN SDK V2.1.
|
|
23
|
+
*/
|
|
19
24
|
export type AddToCartCallback = (
|
|
20
25
|
event: AddToCartEvent
|
|
21
26
|
) => Promise<AddToCartResult | undefined | null>;
|
|
22
27
|
|
|
28
|
+
export type ShoppingCTACallback = (
|
|
29
|
+
event: ShoppingCTAEvent
|
|
30
|
+
) => Promise<ShoppingCTAResult>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated The type will be deprecated since RN SDK V2.0.
|
|
34
|
+
*/
|
|
23
35
|
export type ClickCartIconCallback = () => Promise<
|
|
24
36
|
NewNativeContainerProps | undefined | null
|
|
25
37
|
>;
|
|
@@ -30,6 +42,9 @@ export type UpdateProductDetailsCallback = (
|
|
|
30
42
|
event: UpdateProductDetailsEvent
|
|
31
43
|
) => Promise<Product[] | undefined | null>;
|
|
32
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated The type will be deprecated since RN SDK V2.0.
|
|
47
|
+
*/
|
|
33
48
|
export type WillDisplayProductCallback = (
|
|
34
49
|
event: WillDisplayProductEvent
|
|
35
50
|
) => Promise<ProductInfoViewConfiguration | undefined | null>;
|
|
@@ -49,14 +64,23 @@ class VideoShopping {
|
|
|
49
64
|
*
|
|
50
65
|
* The host apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.
|
|
51
66
|
* If the host apps want to customize the processing logic of clicking "Add to cart" button, they could return null or undefined in the callback.
|
|
67
|
+
* @deprecated The callback will be deprecated since RN SDK V2.1.
|
|
52
68
|
*/
|
|
53
69
|
public onAddToCart?: AddToCartCallback;
|
|
54
70
|
|
|
71
|
+
/**
|
|
72
|
+
* This callback is triggered when the user clicks the "Add to cart" or "Shop now" button.
|
|
73
|
+
* The host app can return a ShoppingCTAResult object to tell SDK how to handle the result.
|
|
74
|
+
*/
|
|
75
|
+
public onShoppingCTA?: ShoppingCTACallback;
|
|
76
|
+
|
|
55
77
|
/**
|
|
56
78
|
* This callback is triggered when the user clicks the shopping cart icon.
|
|
57
79
|
*
|
|
58
80
|
* The host app can return NewNativeContainerProps object
|
|
59
81
|
* and we will push a new native container with the props.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated The property will be deprecated since RN SDK V2.0.
|
|
60
84
|
*/
|
|
61
85
|
public onClickCartIcon?: ClickCartIconCallback;
|
|
62
86
|
|
|
@@ -89,7 +113,8 @@ class VideoShopping {
|
|
|
89
113
|
/**
|
|
90
114
|
* Please use productInfoViewConfiguration property. Only supported on iOS.
|
|
91
115
|
*
|
|
92
|
-
* @deprecated The property will be deprecated since RN SDK V2.
|
|
116
|
+
* @deprecated The property will be deprecated since RN SDK V2.0.
|
|
117
|
+
* Use {@link productInfoViewConfiguration} instead.
|
|
93
118
|
*/
|
|
94
119
|
public onWillDisplayProduct?: WillDisplayProductCallback;
|
|
95
120
|
|
|
@@ -107,8 +132,9 @@ class VideoShopping {
|
|
|
107
132
|
private _cartIconVisible: boolean = true;
|
|
108
133
|
|
|
109
134
|
/**
|
|
110
|
-
* The
|
|
111
|
-
*
|
|
135
|
+
* The configuration of product info view.
|
|
136
|
+
* Please refer to {@link ProductInfoViewConfiguration} for more details.
|
|
137
|
+
* Only supported on iOS.
|
|
112
138
|
*/
|
|
113
139
|
public get productInfoViewConfiguration():
|
|
114
140
|
| ProductInfoViewConfiguration
|
|
@@ -145,9 +171,7 @@ class VideoShopping {
|
|
|
145
171
|
value: CustomClickLinkButtonCallback | undefined
|
|
146
172
|
) {
|
|
147
173
|
this._onCustomClickLinkButton = value;
|
|
148
|
-
|
|
149
|
-
ShoppingModule.setCustomClickLinkButtonEnabled(!!value);
|
|
150
|
-
}
|
|
174
|
+
ShoppingModule.setCustomClickLinkButtonEnabled(!!value);
|
|
151
175
|
}
|
|
152
176
|
private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;
|
|
153
177
|
|
|
@@ -165,12 +189,26 @@ class VideoShopping {
|
|
|
165
189
|
}
|
|
166
190
|
|
|
167
191
|
private constructor() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
192
|
+
if (Platform.OS === 'android') {
|
|
193
|
+
this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {
|
|
194
|
+
FWLoggerUtil.log(
|
|
195
|
+
`Receive AddToCart event productId: ${event?.productId} unitId: ${event?.unitId}`
|
|
196
|
+
);
|
|
197
|
+
this.handleShoppingCTAEvent(event);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (Platform.OS === 'ios') {
|
|
202
|
+
this.eventEmitter.addListener(
|
|
203
|
+
FWEventName.ShoppingCTAButtonClick,
|
|
204
|
+
(event) => {
|
|
205
|
+
FWLoggerUtil.log(
|
|
206
|
+
`Receive ShoppingCTA event productId: ${event?.productId} unitId: ${event?.unitId} url: ${event?.url}`
|
|
207
|
+
);
|
|
208
|
+
this.handleShoppingCTAEvent(event);
|
|
209
|
+
}
|
|
171
210
|
);
|
|
172
|
-
|
|
173
|
-
});
|
|
211
|
+
}
|
|
174
212
|
|
|
175
213
|
this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {
|
|
176
214
|
FWLoggerUtil.log('Receive ClickCartIcon event');
|
|
@@ -192,17 +230,15 @@ class VideoShopping {
|
|
|
192
230
|
});
|
|
193
231
|
this.eventEmitter.addListener(FWEventName.LogMessage, () => {});
|
|
194
232
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
);
|
|
205
|
-
}
|
|
233
|
+
this.eventEmitter.addListener(
|
|
234
|
+
FWEventName.CustomLinkButtonClick,
|
|
235
|
+
(event) => {
|
|
236
|
+
FWLoggerUtil.log(
|
|
237
|
+
`Receive CustomLinkButtonClick event url: ${event?.url}`
|
|
238
|
+
);
|
|
239
|
+
this.handleCustomLinkButtonClickEvent(event);
|
|
240
|
+
}
|
|
241
|
+
);
|
|
206
242
|
}
|
|
207
243
|
|
|
208
244
|
/**
|
|
@@ -217,30 +253,69 @@ class VideoShopping {
|
|
|
217
253
|
ShoppingModule.setCartItemCount(count);
|
|
218
254
|
}
|
|
219
255
|
|
|
220
|
-
private async
|
|
256
|
+
private async handleShoppingCTAEvent(event: any) {
|
|
221
257
|
const callbackId = event.callbackId;
|
|
222
258
|
delete event.callbackId;
|
|
223
|
-
|
|
259
|
+
let isShopNowCTA = false;
|
|
260
|
+
if (
|
|
261
|
+
Platform.OS === 'ios' &&
|
|
262
|
+
this.productInfoViewConfiguration?.ctaButton?.text === 'shopNow'
|
|
263
|
+
) {
|
|
264
|
+
isShopNowCTA = true;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (this.onShoppingCTA) {
|
|
268
|
+
const result = await this.onShoppingCTA(event as ShoppingCTAEvent);
|
|
269
|
+
if (callbackId) {
|
|
270
|
+
if (Platform.OS === 'ios') {
|
|
271
|
+
ShoppingModule.updateShoppingCTAResult(result, callbackId);
|
|
272
|
+
} else {
|
|
273
|
+
if (result.tips) {
|
|
274
|
+
ShoppingModule.updateAddToCartStatus(
|
|
275
|
+
result.res,
|
|
276
|
+
result.tips,
|
|
277
|
+
callbackId
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} else if (this.onAddToCart && !isShopNowCTA) {
|
|
283
|
+
if (event.url) {
|
|
284
|
+
delete event.url;
|
|
285
|
+
}
|
|
224
286
|
const result = await this.onAddToCart(event as AddToCartEvent);
|
|
225
287
|
if (result) {
|
|
226
288
|
if (callbackId) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
289
|
+
if (Platform.OS === 'ios') {
|
|
290
|
+
ShoppingModule.updateShoppingCTAResult(
|
|
291
|
+
{ res: result.res, tips: result.tips },
|
|
292
|
+
callbackId
|
|
293
|
+
);
|
|
294
|
+
} else {
|
|
295
|
+
ShoppingModule.updateAddToCartStatus(
|
|
296
|
+
result.res,
|
|
297
|
+
result.tips ?? '',
|
|
298
|
+
callbackId
|
|
299
|
+
);
|
|
300
|
+
}
|
|
232
301
|
}
|
|
233
302
|
} else {
|
|
234
303
|
if (callbackId) {
|
|
235
304
|
if (Platform.OS === 'ios') {
|
|
236
|
-
ShoppingModule.clearCallbackId(
|
|
305
|
+
ShoppingModule.clearCallbackId(
|
|
306
|
+
callbackId,
|
|
307
|
+
FWEventName.ShoppingCTAButtonClick
|
|
308
|
+
);
|
|
237
309
|
}
|
|
238
310
|
}
|
|
239
311
|
}
|
|
240
312
|
} else {
|
|
241
313
|
if (callbackId) {
|
|
242
314
|
if (Platform.OS === 'ios') {
|
|
243
|
-
ShoppingModule.clearCallbackId(
|
|
315
|
+
ShoppingModule.clearCallbackId(
|
|
316
|
+
callbackId,
|
|
317
|
+
FWEventName.ShoppingCTAButtonClick
|
|
318
|
+
);
|
|
244
319
|
}
|
|
245
320
|
}
|
|
246
321
|
}
|
|
@@ -314,7 +389,7 @@ class VideoShopping {
|
|
|
314
389
|
event as WillDisplayProductEvent
|
|
315
390
|
);
|
|
316
391
|
if (config) {
|
|
317
|
-
|
|
392
|
+
this.productInfoViewConfiguration = config;
|
|
318
393
|
}
|
|
319
394
|
}
|
|
320
395
|
}
|