airbridge-react-native-sdk
Version:
Airbridge SDK for React Native
81 lines (62 loc) • 1.89 kB
text/typescript
import { NativeModules } from 'react-native'
import { createInteractor } from '../architecture/Interactor'
export const createDependency = () => {}
type SwitchInteractor = {
enableSDK(): void
disableSDK(): void
isSDKEnabled(): Promise<boolean>
startTracking(): void
stopTracking(): void
isTrackingEnabled(): Promise<boolean>
startInAppPurchaseTracking(): void
stopInAppPurchaseTracking(): void
isInAppPurchaseTrackingEnabled(): Promise<boolean>
}
createDependency.SwitchModule = () => ({
interactor: createInteractor<SwitchInteractor>(NativeModules.SwitchInteractor),
})
export type SwitchModule = ReturnType<typeof createSwitchModule>
export const createSwitchModule= () => {
// create dependency
const { interactor } = createDependency.SwitchModule()
// define method
const enableSDK = () => {
interactor.enableSDK()
}
const disableSDK = () => {
interactor.disableSDK()
}
const isSDKEnabled = () => {
return interactor.isSDKEnabled()
}
const startTracking = () => {
interactor.startTracking()
}
const stopTracking = () => {
interactor.stopTracking()
}
const isTrackingEnabled = () => {
return interactor.isSDKEnabled()
}
const startInAppPurchaseTracking = () => {
interactor.startInAppPurchaseTracking()
}
const stopInAppPurchaseTracking = () => {
interactor.stopInAppPurchaseTracking()
}
const isInAppPurchaseTrackingEnabled = () => {
return interactor.isInAppPurchaseTrackingEnabled()
}
// create object
return {
enableSDK,
disableSDK,
isSDKEnabled,
startTracking,
stopTracking,
isTrackingEnabled,
startInAppPurchaseTracking,
stopInAppPurchaseTracking,
isInAppPurchaseTrackingEnabled,
}
}