-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make MaBulle version work without IAP
In b056a90 we added code to dynamically remove IAP package using white_label mechanism This correctly removed the IAP package and allowed to build the app But since then, we added some react-native components that use the module and would break when removing the IAP package (react-native module is available, but the native part is not loaded) To make them work without IAP package, we choose to move the import behind a proxy file. Then we can override this file using white_labels and instead import stubbed methods The mandatory methods are `withIAPContext` and `useIAP` that wrap the entire components and `getSubscriptions` that is used to enable/disable IAP features Other methods can still be exported as is as they would never be called when IAP features are disabled Related commit: b056a90 Related PR: #1188
- Loading branch information
Showing
7 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from 'react-native-iap' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
white_label/brands/cozy/js/app/domain/iap/services/iapModule.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from 'react-native-iap' |
46 changes: 46 additions & 0 deletions
46
white_label/brands/mabulle/js/app/domain/iap/services/iapModule.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Subscription[]> => { | ||
return Promise.resolve([]) | ||
} | ||
|
||
export function withIAPContext(Component: React.ComponentType) { | ||
return function WrapperComponent( | ||
props: JSX.IntrinsicAttributes | ||
): JSX.Element { | ||
return <Component {...props} /> | ||
} | ||
} | ||
|
||
export const useIAP = (): useIAPResult => { | ||
const subscriptions: Subscription[] = [] | ||
const getSubscriptions = ({ skus }: { skus: string[] }): Promise<void> => { | ||
return Promise.resolve() | ||
} | ||
return { subscriptions, getSubscriptions } | ||
} | ||
|
||
interface useIAPResult { | ||
subscriptions: Subscription[] | ||
getSubscriptions: ({ skus }: { skus: string[] }) => Promise<void> | ||
} |