96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import { NativeModules } from 'react-native';
|
|
import { GenericObject } from '@common/GenericTypes';
|
|
import { CLICKSTREAM_EVENT_NAMES } from '@common/Constants';
|
|
import { addClickstreamEvent } from '@services/clickstreamEventService';
|
|
|
|
interface CrashError {
|
|
message: string;
|
|
screenName: string;
|
|
}
|
|
|
|
const { DeviceUtilsModule, RNRestart, SimDetails } = NativeModules; // this is the same name we returned in getName function.
|
|
|
|
export const restartJSBundle = () => RNRestart.restart();
|
|
|
|
// returns true if enabled, and false if disabled.
|
|
export const locationEnabled = (): Promise<boolean> => DeviceUtilsModule.isLocationEnabled();
|
|
|
|
// returns array of all the installed packages.
|
|
export const getAllInstalledApp = (): Promise<string> => DeviceUtilsModule.getAllInstalledApp();
|
|
|
|
export type BuildFlavour = 'fieldAgents' | 'callingAgents';
|
|
|
|
export const getBuildFlavour = (): Promise<BuildFlavour> => DeviceUtilsModule.getBuildFlavour();
|
|
|
|
export type buildConfig = {
|
|
versionCode: number;
|
|
versionName: string;
|
|
};
|
|
|
|
export const getBuildInfo = (): Promise<string> => DeviceUtilsModule.getBuildInfo();
|
|
|
|
export const getBlacklistedApps = (
|
|
blacklistedAppsObject: Record<string, boolean>
|
|
): Promise<string> => DeviceUtilsModule.getBlacklistedApps(blacklistedAppsObject);
|
|
|
|
export const alfredHandleSWWEvent = (error: Error) => {
|
|
const { message = '', stack = '', name = '' } = error;
|
|
|
|
DeviceUtilsModule.handleSWWEvent(message, stack, name);
|
|
};
|
|
|
|
export const handleCrash = (error: CrashError) => {
|
|
const { message = '', screenName = '' } = error;
|
|
DeviceUtilsModule.handleCrash(message, screenName);
|
|
};
|
|
|
|
export const handleANR = () => DeviceUtilsModule.handleANR();
|
|
|
|
export const alfredSetPhoneNumber = (phoneNumber: string) =>
|
|
DeviceUtilsModule.setPhoneNumber(phoneNumber);
|
|
|
|
export const alfredSetCodePushVersion = (codePushVersion: string) =>
|
|
DeviceUtilsModule.setCodePushVersion(codePushVersion);
|
|
|
|
export const alfredSetUserId = (userId: string) => DeviceUtilsModule.setUserId(userId);
|
|
|
|
export const sendBottomSheetOpenSignal = (e: boolean) =>
|
|
DeviceUtilsModule.sendBottomSheetOpenSignal(e);
|
|
|
|
export const setBottomSheetView = (id: number | null) => DeviceUtilsModule.setBottomSheetView(id);
|
|
|
|
export const clearBottomSheet = () => DeviceUtilsModule.clearBottomSheet();
|
|
|
|
export const alfredSetEmailId = (emailId: string) => DeviceUtilsModule.setEmailId(emailId);
|
|
|
|
// sends content to whatsapp.
|
|
export const sendContentToWhatsapp = (
|
|
message: string,
|
|
imageUrl: string,
|
|
mimeType: string,
|
|
format: string,
|
|
fileName: string
|
|
): Promise<boolean> =>
|
|
DeviceUtilsModule?.sendContentToWhatsapp(message, imageUrl, mimeType, format, fileName);
|
|
|
|
export const isAppInstalled = (packageName: string): Promise<boolean> =>
|
|
DeviceUtilsModule.isAppInstalled(packageName);
|
|
|
|
export const getAppInfo = (packageName: string): Promise<GenericObject> =>
|
|
DeviceUtilsModule.getAppInfo(packageName);
|
|
|
|
export const getAppInfoFromFilePath = (filePath: string): Promise<GenericObject> =>
|
|
DeviceUtilsModule.getAppInfoFromFilePath(filePath);
|
|
|
|
export const restartApp = (): Promise<boolean> => DeviceUtilsModule.restartApp();
|
|
|
|
export const fetchSimDetails = async () => {
|
|
try {
|
|
const details = await SimDetails.getSimDetails();
|
|
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_FETCH_SIM_DETAILS, { details });
|
|
return details;
|
|
} catch (err) {
|
|
return null;
|
|
}
|
|
};
|