diff --git a/src/app/domain/iap/services/availableOffers.ts b/src/app/domain/iap/services/availableOffers.ts index 076c2996d..fe47e0b8d 100644 --- a/src/app/domain/iap/services/availableOffers.ts +++ b/src/app/domain/iap/services/availableOffers.ts @@ -1,8 +1,8 @@ import { Platform } from 'react-native' -import { getSubscriptions as iapGetSubscriptions } from 'react-native-iap' import Minilog from 'cozy-minilog' +import { getSubscriptions as iapGetSubscriptions } from '/app/domain/iap/services/iapModule' import { getErrorMessage } from '/libs/functions/getErrorMessage' const log = Minilog('💳 Available IAP Offers') diff --git a/src/app/domain/iap/services/clouderyOffer.ts b/src/app/domain/iap/services/clouderyOffer.ts index a68d3e59d..550892235 100644 --- a/src/app/domain/iap/services/clouderyOffer.ts +++ b/src/app/domain/iap/services/clouderyOffer.ts @@ -2,6 +2,12 @@ import { EventEmitter } from 'events' import { Dispatch, SetStateAction } from 'react' import { Linking, Platform } from 'react-native' +import type { WebViewNavigation } from 'react-native-webview/lib/WebViewTypes' + +import CozyClient from 'cozy-client' +import type { InstanceInfo } from 'cozy-client/types/types' +import Minilog from 'cozy-minilog' + import { clearTransactionIOS, ProrationModesAndroid, @@ -9,13 +15,7 @@ import { Subscription, SubscriptionAndroid, SubscriptionOffer -} from 'react-native-iap' -import type { WebViewNavigation } from 'react-native-webview/lib/WebViewTypes' - -import CozyClient from 'cozy-client' -import type { InstanceInfo } from 'cozy-client/types/types' -import Minilog from 'cozy-minilog' - +} from '/app/domain/iap/services/iapModule' import { BuyingState } from '/app/view/IAP/hooks/useClouderyOffer' import { getErrorMessage } from '/libs/functions/getErrorMessage' diff --git a/src/app/domain/iap/services/iapModule.tsx b/src/app/domain/iap/services/iapModule.tsx new file mode 100644 index 000000000..d789df2a6 --- /dev/null +++ b/src/app/domain/iap/services/iapModule.tsx @@ -0,0 +1 @@ +export * from 'react-native-iap' diff --git a/src/app/view/IAP/ClouderyOffer.tsx b/src/app/view/IAP/ClouderyOffer.tsx index 844eb4e50..b5c32d938 100644 --- a/src/app/view/IAP/ClouderyOffer.tsx +++ b/src/app/view/IAP/ClouderyOffer.tsx @@ -1,11 +1,11 @@ import React, { useState } from 'react' import { StyleSheet, Text, TouchableOpacity, View } from 'react-native' -import { withIAPContext } from 'react-native-iap' import WebView from 'react-native-webview' import type { WebViewNavigation } from 'react-native-webview/lib/WebViewTypes' import { FlagshipUI } from 'cozy-intent' +import { withIAPContext } from '/app/domain/iap/services/iapModule' import { ScreenIndexes, useFlagshipUI } from '/app/view/FlagshipUI' import { useClouderyOffer } from '/app/view/IAP/hooks/useClouderyOffer' import { IapProgress } from '/app/view/IAP/IapProgress' diff --git a/src/app/view/IAP/hooks/useClouderyOffer.ts b/src/app/view/IAP/hooks/useClouderyOffer.ts index d1120b9a8..c9ffc1d6c 100644 --- a/src/app/view/IAP/hooks/useClouderyOffer.ts +++ b/src/app/view/IAP/hooks/useClouderyOffer.ts @@ -1,5 +1,4 @@ import { Dispatch, SetStateAction, useEffect, useState } from 'react' -import { initConnection, useIAP } from 'react-native-iap' import { getLocales } from 'react-native-localize' import Toast from 'react-native-toast-message' import type { WebViewNavigation } from 'react-native-webview/lib/WebViewTypes' @@ -15,6 +14,7 @@ import { buySubscription, formatOffers } from '/app/domain/iap/services/clouderyOffer' +import { initConnection, useIAP } from '/app/domain/iap/services/iapModule' import { getErrorMessage } from '/libs/functions/getErrorMessage' import { t } from '/locales/i18n' diff --git a/white_label/brands/cozy/js/app/domain/iap/services/iapModule.tsx b/white_label/brands/cozy/js/app/domain/iap/services/iapModule.tsx new file mode 100644 index 000000000..d789df2a6 --- /dev/null +++ b/white_label/brands/cozy/js/app/domain/iap/services/iapModule.tsx @@ -0,0 +1 @@ +export * from 'react-native-iap' diff --git a/white_label/brands/mabulle/js/app/domain/iap/services/iapModule.tsx b/white_label/brands/mabulle/js/app/domain/iap/services/iapModule.tsx new file mode 100644 index 000000000..f691528a9 --- /dev/null +++ b/white_label/brands/mabulle/js/app/domain/iap/services/iapModule.tsx @@ -0,0 +1,46 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import React from 'react' +import { Subscription } from 'react-native-iap' + +export { + clearTransactionIOS, + ProrationModesAndroid, + requestSubscription +} from 'react-native-iap' + +export type { + Subscription, + SubscriptionAndroid, + SubscriptionOffer +} from 'react-native-iap' + +export { initConnection } from 'react-native-iap' + +export const getSubscriptions = ({ + skus +}: { + skus: string[] +}): Promise => { + return Promise.resolve([]) +} + +export function withIAPContext(Component: React.ComponentType) { + return function WrapperComponent( + props: JSX.IntrinsicAttributes + ): JSX.Element { + return + } +} + +export const useIAP = (): useIAPResult => { + const subscriptions: Subscription[] = [] + const getSubscriptions = ({ skus }: { skus: string[] }): Promise => { + return Promise.resolve() + } + return { subscriptions, getSubscriptions } +} + +interface useIAPResult { + subscriptions: Subscription[] + getSubscriptions: ({ skus }: { skus: string[] }) => Promise +}