TP-0 | fixes

This commit is contained in:
Aman Chaturvedi
2023-10-17 16:54:48 +05:30
parent 37705adc8c
commit a75e0fdcdd
3 changed files with 9 additions and 6 deletions

View File

@@ -404,9 +404,7 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
useEffect(() => {
let appStateSubscription: NativeEventSubscription;
appStateSubscription = AppState.addEventListener('change', handleAppStateChange);
if (AppState.currentState === AppStates.ACTIVE) {
CosmosForegroundService.start(tasks);
}
CosmosForegroundService.start(tasks);
return () => {
appStateSubscription?.remove();
};

View File

@@ -37,9 +37,6 @@ export const getPermissionsToRequest = async () => {
if (!notificationStatus) {
permissionsToRequest.push(permission);
} else {
if (AppState.currentState !== AppStates.ACTIVE) {
continue;
}
const isFGSRunning = await CosmosForegroundService.isRunning();
if (!isFGSRunning) {
CosmosForegroundService.start();

View File

@@ -1,6 +1,8 @@
import ForegroundService from '@supersami/rn-foreground-service';
import { logError } from '../../components/utlis/errorUtils';
import { GLOBAL } from '../../constants/Global';
import { AppState } from 'react-native';
import { AppStates } from '@types/appStates';
export interface IForegroundTask {
task: () => void;
@@ -34,6 +36,9 @@ class CosmosForegroundService {
private constructor() {}
static async start(tasks?: IForegroundTask[]) {
if (AppState.currentState !== AppStates.ACTIVE) {
return;
}
if (GLOBAL.IS_IMPERSONATED) {
return;
}
@@ -60,6 +65,9 @@ class CosmosForegroundService {
}
static async update() {
if (AppState.currentState !== AppStates.ACTIVE) {
return;
}
if (GLOBAL.IS_IMPERSONATED) {
return;
}