@tyrads.com/tyrads-sdk 3.1.0-beta.0 → 3.2.0-beta.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 (135) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/tyradssdk/TyradsSdkModule.kt +130 -46
  3. package/ios/Tyrads/AcmoAssets.swift +14 -0
  4. package/ios/Tyrads/ApiHeaders.swift +1 -0
  5. package/ios/Tyrads/Tyrads.swift +184 -57
  6. package/ios/Tyrads/WebViewController.swift +27 -3
  7. package/ios/Tyrads/core/utils/AcmoKeyNames.swift +29 -0
  8. package/ios/Tyrads/core/utils/ColorExtension.swift +55 -0
  9. package/ios/Tyrads/core/utils/Services/LocalizationService.swift +175 -0
  10. package/ios/Tyrads/helpers/device_details.swift +148 -46
  11. package/ios/Tyrads/legal/AcmoPrivacyPage.swift +353 -0
  12. package/ios/Tyrads/legal/PrivacyPageController.swift +31 -0
  13. package/ios/Tyrads/user/AcmoUserUpdatePage.swift +302 -0
  14. package/ios/Tyrads/user/AcmoUsersUpdateController.swift +26 -0
  15. package/ios/Tyrads/user/Repository.swift +89 -0
  16. package/ios/TyradsSdk.mm +15 -3
  17. package/ios/TyradsSdk.swift +101 -46
  18. package/lib/commonjs/acmo/core/helpers/native_methods.js +37 -0
  19. package/lib/commonjs/acmo/core/helpers/native_methods.js.map +1 -0
  20. package/lib/commonjs/acmo/core/helpers/numeral.js +19 -0
  21. package/lib/commonjs/acmo/core/helpers/numeral.js.map +1 -0
  22. package/lib/commonjs/acmo/core/services/localization_service.js +164 -0
  23. package/lib/commonjs/acmo/core/services/localization_service.js.map +1 -0
  24. package/lib/commonjs/acmo/core/storage/storage.js +15 -1
  25. package/lib/commonjs/acmo/core/storage/storage.js.map +1 -1
  26. package/lib/commonjs/acmo/modules/dashboard/components/active_offers_button.js +5 -2
  27. package/lib/commonjs/acmo/modules/dashboard/components/active_offers_button.js.map +1 -1
  28. package/lib/commonjs/acmo/modules/dashboard/components/offer_card.js +3 -4
  29. package/lib/commonjs/acmo/modules/dashboard/components/offer_card.js.map +1 -1
  30. package/lib/commonjs/acmo/modules/dashboard/components/offer_list_item.js +12 -6
  31. package/lib/commonjs/acmo/modules/dashboard/components/offer_list_item.js.map +1 -1
  32. package/lib/commonjs/acmo/modules/dashboard/components/premium_empty_widget.js +6 -2
  33. package/lib/commonjs/acmo/modules/dashboard/components/premium_empty_widget.js.map +1 -1
  34. package/lib/commonjs/acmo/modules/dashboard/components/premium_header.js +4 -4
  35. package/lib/commonjs/acmo/modules/dashboard/components/premium_header.js.map +1 -1
  36. package/lib/commonjs/acmo/modules/dashboard/components/premium_loading.js +4 -11
  37. package/lib/commonjs/acmo/modules/dashboard/components/premium_loading.js.map +1 -1
  38. package/lib/commonjs/acmo/modules/dashboard/repository.js +1 -1
  39. package/lib/commonjs/acmo/modules/dashboard/top_offers.js +15 -0
  40. package/lib/commonjs/acmo/modules/dashboard/top_offers.js.map +1 -1
  41. package/lib/commonjs/acmo/modules/localization/localization_context.js +56 -0
  42. package/lib/commonjs/acmo/modules/localization/localization_context.js.map +1 -0
  43. package/lib/commonjs/index.js +39 -5
  44. package/lib/commonjs/index.js.map +1 -1
  45. package/lib/module/acmo/core/helpers/native_methods.js +33 -0
  46. package/lib/module/acmo/core/helpers/native_methods.js.map +1 -0
  47. package/lib/module/acmo/core/helpers/numeral.js +14 -0
  48. package/lib/module/acmo/core/helpers/numeral.js.map +1 -0
  49. package/lib/module/acmo/core/services/localization_service.js +159 -0
  50. package/lib/module/acmo/core/services/localization_service.js.map +1 -0
  51. package/lib/module/acmo/core/storage/storage.js +13 -0
  52. package/lib/module/acmo/core/storage/storage.js.map +1 -1
  53. package/lib/module/acmo/modules/dashboard/components/active_offers_button.js +5 -2
  54. package/lib/module/acmo/modules/dashboard/components/active_offers_button.js.map +1 -1
  55. package/lib/module/acmo/modules/dashboard/components/offer_card.js +3 -3
  56. package/lib/module/acmo/modules/dashboard/components/offer_card.js.map +1 -1
  57. package/lib/module/acmo/modules/dashboard/components/offer_list_item.js +12 -6
  58. package/lib/module/acmo/modules/dashboard/components/offer_list_item.js.map +1 -1
  59. package/lib/module/acmo/modules/dashboard/components/premium_empty_widget.js +6 -2
  60. package/lib/module/acmo/modules/dashboard/components/premium_empty_widget.js.map +1 -1
  61. package/lib/module/acmo/modules/dashboard/components/premium_header.js +4 -4
  62. package/lib/module/acmo/modules/dashboard/components/premium_header.js.map +1 -1
  63. package/lib/module/acmo/modules/dashboard/components/premium_loading.js +5 -12
  64. package/lib/module/acmo/modules/dashboard/components/premium_loading.js.map +1 -1
  65. package/lib/module/acmo/modules/dashboard/repository.js +1 -1
  66. package/lib/module/acmo/modules/dashboard/top_offers.js +15 -0
  67. package/lib/module/acmo/modules/dashboard/top_offers.js.map +1 -1
  68. package/lib/module/acmo/modules/localization/localization_context.js +45 -0
  69. package/lib/module/acmo/modules/localization/localization_context.js.map +1 -0
  70. package/lib/module/index.js +38 -6
  71. package/lib/module/index.js.map +1 -1
  72. package/lib/typescript/commonjs/src/acmo/core/helpers/native_methods.d.ts +6 -0
  73. package/lib/typescript/commonjs/src/acmo/core/helpers/native_methods.d.ts.map +1 -0
  74. package/lib/typescript/commonjs/src/acmo/core/helpers/numeral.d.ts +2 -0
  75. package/lib/typescript/commonjs/src/acmo/core/helpers/numeral.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/src/acmo/core/services/localization_service.d.ts +18 -0
  77. package/lib/typescript/commonjs/src/acmo/core/services/localization_service.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/src/acmo/core/storage/storage.d.ts +1 -0
  79. package/lib/typescript/commonjs/src/acmo/core/storage/storage.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/active_offers_button.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/offer_card.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/offer_list_item.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_empty_widget.d.ts.map +1 -1
  84. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_header.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_loading.d.ts +0 -1
  86. package/lib/typescript/commonjs/src/acmo/modules/dashboard/components/premium_loading.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/src/acmo/modules/dashboard/top_offers.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/src/acmo/modules/localization/localization_context.d.ts +14 -0
  89. package/lib/typescript/commonjs/src/acmo/modules/localization/localization_context.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/index.d.ts +4 -0
  91. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  92. package/lib/typescript/module/src/acmo/core/helpers/native_methods.d.ts +6 -0
  93. package/lib/typescript/module/src/acmo/core/helpers/native_methods.d.ts.map +1 -0
  94. package/lib/typescript/module/src/acmo/core/helpers/numeral.d.ts +2 -0
  95. package/lib/typescript/module/src/acmo/core/helpers/numeral.d.ts.map +1 -0
  96. package/lib/typescript/module/src/acmo/core/services/localization_service.d.ts +18 -0
  97. package/lib/typescript/module/src/acmo/core/services/localization_service.d.ts.map +1 -0
  98. package/lib/typescript/module/src/acmo/core/storage/storage.d.ts +1 -0
  99. package/lib/typescript/module/src/acmo/core/storage/storage.d.ts.map +1 -1
  100. package/lib/typescript/module/src/acmo/modules/dashboard/components/active_offers_button.d.ts.map +1 -1
  101. package/lib/typescript/module/src/acmo/modules/dashboard/components/offer_card.d.ts.map +1 -1
  102. package/lib/typescript/module/src/acmo/modules/dashboard/components/offer_list_item.d.ts.map +1 -1
  103. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_empty_widget.d.ts.map +1 -1
  104. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_header.d.ts.map +1 -1
  105. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_loading.d.ts +0 -1
  106. package/lib/typescript/module/src/acmo/modules/dashboard/components/premium_loading.d.ts.map +1 -1
  107. package/lib/typescript/module/src/acmo/modules/dashboard/top_offers.d.ts.map +1 -1
  108. package/lib/typescript/module/src/acmo/modules/localization/localization_context.d.ts +14 -0
  109. package/lib/typescript/module/src/acmo/modules/localization/localization_context.d.ts.map +1 -0
  110. package/lib/typescript/module/src/index.d.ts +4 -0
  111. package/lib/typescript/module/src/index.d.ts.map +1 -1
  112. package/package.json +2 -6
  113. package/src/acmo/core/helpers/native_methods.ts +43 -0
  114. package/src/acmo/core/helpers/numeral.ts +14 -0
  115. package/src/acmo/core/services/localization_service.ts +200 -0
  116. package/src/acmo/core/storage/storage.ts +14 -0
  117. package/src/acmo/modules/dashboard/components/active_offers_button.tsx +3 -2
  118. package/src/acmo/modules/dashboard/components/offer_card.tsx +3 -3
  119. package/src/acmo/modules/dashboard/components/offer_list_item.tsx +8 -5
  120. package/src/acmo/modules/dashboard/components/premium_empty_widget.tsx +5 -2
  121. package/src/acmo/modules/dashboard/components/premium_header.tsx +6 -5
  122. package/src/acmo/modules/dashboard/components/premium_loading.tsx +2 -8
  123. package/src/acmo/modules/dashboard/repository.ts +1 -1
  124. package/src/acmo/modules/dashboard/top_offers.tsx +18 -3
  125. package/src/acmo/modules/localization/localization_context.tsx +52 -0
  126. package/src/index.tsx +63 -18
  127. package/lib/commonjs/i18n.js +0 -112
  128. package/lib/commonjs/i18n.js.map +0 -1
  129. package/lib/module/i18n.js +0 -107
  130. package/lib/module/i18n.js.map +0 -1
  131. package/lib/typescript/commonjs/src/i18n.d.ts +0 -3
  132. package/lib/typescript/commonjs/src/i18n.d.ts.map +0 -1
  133. package/lib/typescript/module/src/i18n.d.ts +0 -3
  134. package/lib/typescript/module/src/i18n.d.ts.map +0 -1
  135. package/src/i18n.ts +0 -115
@@ -1,8 +1,11 @@
1
1
  import React from 'react';
2
2
  import { View, Text, TouchableOpacity, StyleSheet, ImageBackground } from 'react-native';
3
+ import { useLocalization } from '../../localization/localization_context';
3
4
 
4
5
  const PremiumEmptyView: React.FC<{ onContinue?: () => void, colorPremium?: string}> = ({ onContinue, colorPremium}) => {
5
6
 
7
+ const { t } = useLocalization();
8
+
6
9
  return (
7
10
  <View style={styles.container}>
8
11
  <ImageBackground
@@ -12,7 +15,7 @@ const PremiumEmptyView: React.FC<{ onContinue?: () => void, colorPremium?: strin
12
15
  >
13
16
  <View style={styles.content}>
14
17
  <Text style={[styles.title, { color: 'white', fontFamily: 'Poppins_600SemiBold' }]}>
15
- {'Keep Playing!\nExciting Rewards Await!'}
18
+ {t('data.widget.empty.noOffers')}
16
19
  </Text>
17
20
  <TouchableOpacity
18
21
  style={[styles.button, { backgroundColor: 'white' }]}
@@ -29,7 +32,7 @@ const PremiumEmptyView: React.FC<{ onContinue?: () => void, colorPremium?: strin
29
32
  },
30
33
  ]}
31
34
  >
32
- Continue Playing
35
+ {t('data.widget.button.continuePlaying')}
33
36
  </Text>
34
37
  </TouchableOpacity>
35
38
  </View>
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { View, Text, Image, TouchableOpacity, StyleSheet,} from 'react-native';
3
- import { useTranslation } from 'react-i18next';
3
+ import { useLocalization } from '../../localization/localization_context';
4
4
 
5
5
  interface PremiumHeaderSectionProps {
6
6
  showMore?: boolean;
@@ -9,7 +9,8 @@ interface PremiumHeaderSectionProps {
9
9
  }
10
10
 
11
11
  const PremiumHeaderSection: React.FC<PremiumHeaderSectionProps> = ({ showMore = true, premiumColor, onShowOffers }) => {
12
- const { t } = useTranslation();
12
+ const { t } = useLocalization();
13
+
13
14
  return (
14
15
  <View style={styles.headerContainer}>
15
16
  <View style={styles.leftContainer}>
@@ -20,13 +21,13 @@ const PremiumHeaderSection: React.FC<PremiumHeaderSectionProps> = ({ showMore =
20
21
  />
21
22
  </View>
22
23
  <Text style={[styles.headerText, { color: premiumColor }]} numberOfLines={1} ellipsizeMode="tail">
23
- {t('dashboard.suggested_offers')}
24
+ {t('data.widget.page.title')}
24
25
  </Text>
25
26
  </View>
26
27
  {showMore && (
27
28
  <TouchableOpacity style={styles.rightContainer} onPress={onShowOffers}>
28
29
  <Text style={[styles.moreOffersText, { color: premiumColor }]} numberOfLines={1}>
29
- {t('dashboard.more_offers')}
30
+ {t('data.widget.button.moreOffers')}
30
31
  </Text>
31
32
  <Image
32
33
  source={require('../../../../assets/images/angle_up.png')}
@@ -78,4 +79,4 @@ const styles = StyleSheet.create({
78
79
  },
79
80
  });
80
81
 
81
- export default PremiumHeaderSection;
82
+ export default PremiumHeaderSection;
@@ -6,12 +6,10 @@ import CustomCard from './custom_card';
6
6
 
7
7
  interface PremiumWidgetsLoadingProps {
8
8
  widgetStyle: PremiumWidgetStyles;
9
- itemHeight?: number;
10
9
  }
11
10
 
12
11
  const PremiumWidgetsLoading: React.FC<PremiumWidgetsLoadingProps> = ({
13
12
  widgetStyle,
14
- itemHeight,
15
13
  }) => {
16
14
  return (
17
15
  <CustomCard style={{
@@ -23,7 +21,7 @@ const PremiumWidgetsLoading: React.FC<PremiumWidgetsLoadingProps> = ({
23
21
  <Shimmer style={{ width: 105, height: 18, borderRadius: 4 }} />
24
22
  </View>
25
23
 
26
- {widgetStyle === PremiumWidgetStyles.list ? (
24
+ {widgetStyle === PremiumWidgetStyles.list && (
27
25
  <View style={styles.listContainer}>
28
26
  {[...Array(4)].map((_, index) => (
29
27
  <View key={index} style={styles.listTile}>
@@ -38,14 +36,10 @@ const PremiumWidgetsLoading: React.FC<PremiumWidgetsLoadingProps> = ({
38
36
  </View>
39
37
  ))}
40
38
  </View>
41
- ) : (
42
- <>
43
- <Shimmer style={{ width: '100%', height: itemHeight }} />
44
- </>
45
39
  )}
46
40
 
47
41
  {widgetStyle === PremiumWidgetStyles.sliderCards && (
48
- <Shimmer shimmerHeight={150} style={{ flexDirection: 'row', height: 150, }} />
42
+ <Shimmer shimmerHeight={150} style={{ flexDirection: 'row', height: 150, marginTop: 16 }} />
49
43
  )}
50
44
 
51
45
  <Shimmer shimmerHeight={42} style={{ flexDirection: 'row', height: 42, borderRadius: 21, marginVertical: 16 }} />
@@ -63,7 +63,7 @@ export const fetchPremiumOfferDetails = async (
63
63
  // "bannerUrl": "",
64
64
  // "dateStart": "2025-03-10T00:00:00.000Z",
65
65
  // "dateEnd": "2025-03-10T23:59:59.000Z",
66
- // remainingTimeSeconds: undefined
66
+ // remainingTimeSeconds: 3090
67
67
  // };
68
68
 
69
69
  setCampaigns(hotOffers);
@@ -13,6 +13,7 @@ import AcmoOfferCard from './components/offer_card';
13
13
  import AcmoScrollPager from './components/custom_scroller';
14
14
  import PremiumEmptyView from './components/premium_empty_widget';
15
15
  import PremiumWidgetsLoading from './components/premium_loading';
16
+ import TyradsNativeMethods from '../../core/helpers/native_methods';
16
17
 
17
18
  export const enum PremiumWidgetStyles {
18
19
  list,
@@ -36,7 +37,6 @@ const PremiumWidgets: React.FC<PremiumWidgetProps> = ({
36
37
  const [activeCount, setActiveCount] = useState<number>(0);
37
38
  const [loadingIndex, setLoadingIndex] = useState<number | null>(null);
38
39
 
39
-
40
40
  useEffect(() => {
41
41
  fetchPremiumOfferDetails(
42
42
  setPremiumColor,
@@ -44,8 +44,9 @@ const PremiumWidgets: React.FC<PremiumWidgetProps> = ({
44
44
  setCurrencySale,
45
45
  setActiveCount,
46
46
  setError,
47
- setIsLoading
47
+ setIsLoading,
48
48
  );
49
+
49
50
  }, []);
50
51
 
51
52
  const handleShowOffers = () => {
@@ -60,6 +61,20 @@ const PremiumWidgets: React.FC<PremiumWidgetProps> = ({
60
61
  };
61
62
 
62
63
  const handleButtonPress = async (campaign: Campaign) => {
64
+ let isReady = await TyradsNativeMethods.isPrivacyAccepted()
65
+ if (!isReady) {
66
+ try {
67
+ const result = await TyradsNativeMethods.checkOnboardingProcess();
68
+ console.log("Privacy flow result:", result);
69
+ isReady = result === true;
70
+ } catch (err) {
71
+ console.error("Privacy flow error:", err);
72
+ isReady = false;
73
+ }
74
+ }
75
+ if (!isReady) {
76
+ return
77
+ }
63
78
  await openOffer(campaign);
64
79
  await fetchPremiumOfferDetails(
65
80
  setPremiumColor,
@@ -67,7 +82,7 @@ const PremiumWidgets: React.FC<PremiumWidgetProps> = ({
67
82
  setCurrencySale,
68
83
  setActiveCount,
69
84
  setError,
70
- setIsLoading
85
+ setIsLoading,
71
86
  );
72
87
  }
73
88
 
@@ -0,0 +1,52 @@
1
+ import React, { createContext, useContext, useState, useEffect } from 'react';
2
+ import LocalizationService from '../../core/services/localization_service';
3
+
4
+ interface LocalizationContextProps {
5
+ t: (key: string, args?: Record<string, string | number>) => string;
6
+ changeLanguage: (lang: string) => Promise<void>;
7
+ currentLanguage: string;
8
+ }
9
+
10
+ const LocalizationContext = createContext<LocalizationContextProps>({
11
+ t: (key) => key,
12
+ changeLanguage: async () => {},
13
+ currentLanguage: 'en',
14
+ });
15
+
16
+ let _updateLanguage: ((lang: string) => void) | null = null;
17
+
18
+ export const LocalizationProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
19
+ const [currentLanguage, setCurrentLanguage] = useState('en');
20
+ const service = LocalizationService.getInstance();
21
+
22
+ useEffect(() => {
23
+ _updateLanguage = setCurrentLanguage;
24
+ }, []);
25
+
26
+ const changeLanguage = async (lang: string) => {
27
+ await service.changeLanguage(lang);
28
+ setCurrentLanguage(lang);
29
+ };
30
+
31
+ const t = (key: string, args?: Record<string, string | number>) => service.translate(key, args);
32
+
33
+ return (
34
+ <LocalizationContext.Provider value={{ t, changeLanguage, currentLanguage }}>
35
+ {children}
36
+ </LocalizationContext.Provider>
37
+ );
38
+ };
39
+
40
+ export const useLocalization = () => useContext(LocalizationContext);
41
+
42
+ export const updateProviderLanguage = async (lang: string) => {
43
+ const service = LocalizationService.getInstance();
44
+ await service.init(lang);
45
+ _updateLanguage?.(lang);
46
+ };
47
+
48
+ export const changeProviderLanguage = async (lang: string) => {
49
+ const service = LocalizationService.getInstance();
50
+ await service.changeLanguage(lang);
51
+ _updateLanguage?.(lang);
52
+ };
package/src/index.tsx CHANGED
@@ -1,9 +1,10 @@
1
- import { NativeModules, Platform, View,} from 'react-native';
1
+ import { NativeEventEmitter, NativeModules, Platform, View, } from 'react-native';
2
2
 
3
3
  import TopOffers, { PremiumWidgetStyles } from './acmo/modules/dashboard/top_offers';
4
4
  import { saveData } from './acmo/core/storage/storage';
5
- import { I18nextProvider } from 'react-i18next';
6
- import i18n from './i18n';
5
+ import Localization from './acmo/core/services/localization_service';
6
+ import { changeProviderLanguage, LocalizationProvider, updateProviderLanguage } from './acmo/modules/localization/localization_context';
7
+ import PremiumWidgetsLoading from './acmo/modules/dashboard/components/premium_loading';
7
8
 
8
9
  // const TyradsSdkComposeView = requireNativeComponent('TyradsSdkComposeView');
9
10
 
@@ -17,23 +18,54 @@ const LINKING_ERROR =
17
18
  const TyradsSdk = NativeModules.TyradsSdk
18
19
  ? NativeModules.TyradsSdk
19
20
  : new Proxy(
20
- {},
21
- {
22
- get() {
23
- throw new Error(LINKING_ERROR);
24
- },
25
- }
26
- );
21
+ {},
22
+ {
23
+ get() {
24
+ throw new Error(LINKING_ERROR);
25
+ },
26
+ }
27
+ );
28
+
29
+ const tyradsEmitter = new NativeEventEmitter(TyradsSdk);
30
+
31
+ let languageChangedSubscription: any = null;
27
32
 
28
33
  const Tyrads = {
29
34
  init: async (apiKey: string, apiSecret: string, encKey?: string) => {
30
35
  const data = await TyradsSdk.init(apiKey, apiSecret, encKey);
36
+
37
+ await saveData("credentials", {
38
+ 'X-API-Key': apiKey,
39
+ 'X-API-Secret': apiSecret
40
+ });
41
+
42
+ let languageCode = "en";
43
+ try {
44
+ const parsed = typeof data === "string" ? JSON.parse(data) : data;
45
+ if (parsed?.languageCode) {
46
+ languageCode = parsed.languageCode;
47
+ }
48
+ } catch { }
49
+
50
+ TyradsSdk.startObserving();
51
+ languageChangedSubscription?.remove();
52
+ languageChangedSubscription = tyradsEmitter.addListener(
53
+ 'LanguageChanged',
54
+ async (lang: string) => {
55
+ console.log('LanguageChanged event from Android SDK:', lang);
56
+ await changeProviderLanguage(lang);
57
+ }
58
+ );
59
+
60
+ await saveData("language", languageCode);
61
+ await Localization.getInstance().init(languageCode);
62
+ await updateProviderLanguage(languageCode);
63
+
31
64
  return data;
32
65
  },
33
66
  loginUser: async (userId: string) => {
34
67
  try {
35
68
  const data = await TyradsSdk.loginUser(userId);
36
-
37
69
  if (typeof data === "object") {
38
70
  await saveData('apiHeaders', JSON.stringify(data));
39
71
  await saveData('language', data.languageCode);
@@ -41,25 +73,24 @@ const Tyrads = {
41
73
  await saveData('apiHeaders', data);
42
74
  await saveData('language', JSON.parse(data).languageCode);
43
75
  }
44
-
45
76
  return data;
46
77
  } catch (err) {
47
78
  return null;
48
79
  }
49
80
  },
50
-
81
+
51
82
  showOffers: async ({
52
83
  launchMode = 3,
53
84
  route,
54
85
  campaignID,
55
86
  }: { launchMode?: number; route?: string; campaignID?: number | null } = {}) => {
56
87
  if (Platform.OS === 'ios') {
57
- if(campaignID == null) {
88
+ if (campaignID == null) {
58
89
  return await TyradsSdk.showOffers(launchMode, route);
59
90
  }
60
91
  return await TyradsSdk.showOfferDetails(launchMode, route, campaignID);
61
92
  } else {
62
- if(campaignID == null) {
93
+ if (campaignID == null) {
63
94
  return await TyradsSdk.showOffers(route);
64
95
  }
65
96
  return await TyradsSdk.showOfferDetails(route, campaignID);
@@ -73,19 +104,33 @@ const Tyrads = {
73
104
  launchMode?: number;
74
105
  } = {}) => {
75
106
  const handleNavigation = (route?: string, campaignID?: number | null) => {
76
- Tyrads.showOffers({ route: route, campaignID: campaignID, launchMode: launchMode});
107
+ Tyrads.showOffers({ route: route, campaignID: campaignID, launchMode: launchMode });
77
108
  };
78
109
  return (
79
- <I18nextProvider i18n={i18n}>
110
+ <LocalizationProvider>
80
111
  <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
81
112
  <TopOffers
82
113
  widgetStyle={widgetStyle}
83
114
  onNavigate={handleNavigation}
84
115
  />
85
116
  </View>
86
- </I18nextProvider>
117
+ </LocalizationProvider>
87
118
  );
88
119
  },
120
+ topPremiumOffersLoading: (
121
+ { widgetStyle = PremiumWidgetStyles.list }: {
122
+ widgetStyle?: PremiumWidgetStyles;
123
+ }
124
+ ) => {
125
+ return (
126
+ <PremiumWidgetsLoading
127
+ widgetStyle={widgetStyle}
128
+ />
129
+ );
130
+ },
131
+ changeLanguage: async (lang: string) => {
132
+ return await TyradsSdk.changeLanguage(lang);
133
+ },
89
134
  };
90
135
 
91
136
  export default Tyrads;
@@ -1,112 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _i18next = _interopRequireDefault(require("i18next"));
8
- var _reactI18next = require("react-i18next");
9
- var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const resources = {
12
- en: {
13
- translation: {
14
- "dashboard": {
15
- "suggested_offers": "Suggested Offers",
16
- "more_offers": "More Offers",
17
- "my_games": "My Games",
18
- "play_button": "Play Now",
19
- "top_ranking": "Top {{number}}",
20
- "rewards_one": "Reward",
21
- "rewards_other": "Rewards"
22
- }
23
- }
24
- },
25
- es: {
26
- translation: {
27
- "dashboard": {
28
- "suggested_offers": "Ofertas sugeridas",
29
- "more_offers": "Más ofertas",
30
- "my_games": "Mis juegos",
31
- "play_button": "Jugar Ahora",
32
- "top_ranking": "Los mejores {{number}}",
33
- "rewards_one": "Recompensa",
34
- "rewards_other": "Recompensas"
35
- }
36
- }
37
- },
38
- id: {
39
- translation: {
40
- "dashboard": {
41
- "suggested_offers": "Penawaran yang Disarankan",
42
- "more_offers": "Penawaran Lainnya",
43
- "my_games": "Permainan Saya",
44
- "play_button": "Mainkan Sekarang",
45
- "top_ranking": "Top {{number}}",
46
- "rewards_one": "Hadiah",
47
- "rewards_other": "Hadiah"
48
- }
49
- }
50
- },
51
- in: {
52
- translation: {
53
- "dashboard": {
54
- "suggested_offers": "Penawaran yang Disarankan",
55
- "more_offers": "Penawaran Lainnya",
56
- "my_games": "Permainan Saya",
57
- "play_button": "Mainkan Sekarang",
58
- "top_ranking": "Top {{number}}",
59
- "rewards_one": "Hadiah",
60
- "rewards_other": "Hadiah"
61
- }
62
- }
63
- },
64
- ja: {
65
- translation: {
66
- "dashboard": {
67
- "suggested_offers": "おすすめのオファー",
68
- "more_offers": "その他のオファー",
69
- "my_games": "マイゲーム",
70
- "play_button": "プレイ する",
71
- "top_ranking": "トップ {{number}}",
72
- "rewards_one": "報酬",
73
- "rewards_other": "報酬"
74
- }
75
- }
76
- },
77
- ko: {
78
- translation: {
79
- "dashboard": {
80
- "suggested_offers": "추천 제안",
81
- "more_offers": "더 많은 제안",
82
- "my_games": "내 게임",
83
- "play_button": "플레이 하고",
84
- "top_ranking": "상위 {{number}}",
85
- "rewards_one": "보상",
86
- "rewards_other": "보상들"
87
- }
88
- }
89
- }
90
- };
91
- const initializeI18n = async () => {
92
- try {
93
- const language = await _asyncStorage.default.getItem('language');
94
- const storedLanguage = JSON.parse(language);
95
- console.log('storedLanguage', storedLanguage);
96
- const initialLanguage = storedLanguage;
97
- await _i18next.default.use(_reactI18next.initReactI18next).init({
98
- resources,
99
- fallbackLng: 'en',
100
- lng: initialLanguage,
101
- debug: __DEV__,
102
- interpolation: {
103
- escapeValue: false
104
- }
105
- });
106
- } catch (error) {
107
- console.error('Error initializing i18n:', error);
108
- }
109
- };
110
- initializeI18n();
111
- var _default = exports.default = _i18next.default;
112
- //# sourceMappingURL=i18n.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_i18next","_interopRequireDefault","require","_reactI18next","_asyncStorage","e","__esModule","default","resources","en","translation","es","id","in","ja","ko","initializeI18n","language","AsyncStorage","getItem","storedLanguage","JSON","parse","console","log","initialLanguage","i18n","use","initReactI18next","init","fallbackLng","lng","debug","__DEV__","interpolation","escapeValue","error","_default","exports"],"sourceRoot":"../../src","sources":["i18n.ts"],"mappings":";;;;;;AAAA,IAAAA,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@ -1,107 +0,0 @@
1
- "use strict";
2
-
3
- import i18n from 'i18next';
4
- import { initReactI18next } from 'react-i18next';
5
- import AsyncStorage from '@react-native-async-storage/async-storage';
6
- const resources = {
7
- en: {
8
- translation: {
9
- "dashboard": {
10
- "suggested_offers": "Suggested Offers",
11
- "more_offers": "More Offers",
12
- "my_games": "My Games",
13
- "play_button": "Play Now",
14
- "top_ranking": "Top {{number}}",
15
- "rewards_one": "Reward",
16
- "rewards_other": "Rewards"
17
- }
18
- }
19
- },
20
- es: {
21
- translation: {
22
- "dashboard": {
23
- "suggested_offers": "Ofertas sugeridas",
24
- "more_offers": "Más ofertas",
25
- "my_games": "Mis juegos",
26
- "play_button": "Jugar Ahora",
27
- "top_ranking": "Los mejores {{number}}",
28
- "rewards_one": "Recompensa",
29
- "rewards_other": "Recompensas"
30
- }
31
- }
32
- },
33
- id: {
34
- translation: {
35
- "dashboard": {
36
- "suggested_offers": "Penawaran yang Disarankan",
37
- "more_offers": "Penawaran Lainnya",
38
- "my_games": "Permainan Saya",
39
- "play_button": "Mainkan Sekarang",
40
- "top_ranking": "Top {{number}}",
41
- "rewards_one": "Hadiah",
42
- "rewards_other": "Hadiah"
43
- }
44
- }
45
- },
46
- in: {
47
- translation: {
48
- "dashboard": {
49
- "suggested_offers": "Penawaran yang Disarankan",
50
- "more_offers": "Penawaran Lainnya",
51
- "my_games": "Permainan Saya",
52
- "play_button": "Mainkan Sekarang",
53
- "top_ranking": "Top {{number}}",
54
- "rewards_one": "Hadiah",
55
- "rewards_other": "Hadiah"
56
- }
57
- }
58
- },
59
- ja: {
60
- translation: {
61
- "dashboard": {
62
- "suggested_offers": "おすすめのオファー",
63
- "more_offers": "その他のオファー",
64
- "my_games": "マイゲーム",
65
- "play_button": "プレイ する",
66
- "top_ranking": "トップ {{number}}",
67
- "rewards_one": "報酬",
68
- "rewards_other": "報酬"
69
- }
70
- }
71
- },
72
- ko: {
73
- translation: {
74
- "dashboard": {
75
- "suggested_offers": "추천 제안",
76
- "more_offers": "더 많은 제안",
77
- "my_games": "내 게임",
78
- "play_button": "플레이 하고",
79
- "top_ranking": "상위 {{number}}",
80
- "rewards_one": "보상",
81
- "rewards_other": "보상들"
82
- }
83
- }
84
- }
85
- };
86
- const initializeI18n = async () => {
87
- try {
88
- const language = await AsyncStorage.getItem('language');
89
- const storedLanguage = JSON.parse(language);
90
- console.log('storedLanguage', storedLanguage);
91
- const initialLanguage = storedLanguage;
92
- await i18n.use(initReactI18next).init({
93
- resources,
94
- fallbackLng: 'en',
95
- lng: initialLanguage,
96
- debug: __DEV__,
97
- interpolation: {
98
- escapeValue: false
99
- }
100
- });
101
- } catch (error) {
102
- console.error('Error initializing i18n:', error);
103
- }
104
- };
105
- initializeI18n();
106
- export default i18n;
107
- //# sourceMappingURL=i18n.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["i18n","initReactI18next","AsyncStorage","resources","en","translation","es","id","in","ja","ko","initializeI18n","language","getItem","storedLanguage","JSON","parse","console","log","initialLanguage","use","init","fallbackLng","lng","debug","__DEV__","interpolation","escapeValue","error"],"sourceRoot":"../../src","sources":["i18n.ts"],"mappings":";;AAAA,OAAOA,IAAI,MAAM,SAAS;AAC1B,SAASC,gBAAgB,QAAQ,eAAe;AAChD,OAAOC,YAAY,MAAM,2CAA2C;AAGpE,MAAMC,SAAS,GAAG;EAChBC,EAAE,EAAE;IACFC,WAAW,EAAE;MACX,WAAW,EAAE;QACX,kBAAkB,EAAE,kBAAkB;QACtC,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,UAAU;QACtB,aAAa,EAAE,UAAU;QACzB,aAAa,EAAE,gBAAgB;QAC/B,aAAa,EAAE,QAAQ;QACvB,eAAe,EAAE;MACnB;IAGF;EACF,CAAC;EACDC,EAAE,EAAE;IACFD,WAAW,EAAE;MACX,WAAW,EAAE;QACX,kBAAkB,EAAE,mBAAmB;QACvC,aAAa,EAAE,aAAa;QAC5B,UAAU,EAAE,YAAY;QACxB,aAAa,EAAE,aAAa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C,cAAsB,GAAGC,IAAI,CAACC,KAAK,CAACJ,QAAQ,CAAC;IACnDK,OAAO,CAACC,GAAG,CAAC,gBAAgB,EAAEJ,cAAc,CAAC;IAE7C,MAAMK,eAAe,GAAGL,cAAc;IACtC,MAAMd,IAAI,CACPoB,GAAG,CAACnB,gBAAgB,CAAC,CACrBoB,IAAI,CAAC;MACJlB,SAAS;MACTmB,WAAW,EAAE,IAAI;MACjBC,GAAG,EAAEJ,eAAe;MACpBK,KAAK,EAAEC,OAAO;MACdC,aAAa,EAAE;QACbC,WAAW,EAAE;MACf;IACF,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdX,OAAO,CAACW,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAAC;EAClD;AACF,CAAC;AAEDjB,cAAc,CAAC,CAAC;AAEhB,eAAeX,IAAI","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import i18n from 'i18next';
2
- export default i18n;
3
- //# sourceMappingURL=i18n.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../src/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAkH3B,eAAe,IAAI,CAAC"}
@@ -1,3 +0,0 @@
1
- import i18n from 'i18next';
2
- export default i18n;
3
- //# sourceMappingURL=i18n.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../src/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAkH3B,eAAe,IAAI,CAAC"}