Skip to content

duplicate odometer #2438

@otonielloliveira

Description

@otonielloliveira

"react-native": "0.72.4"
"react-native-background-geolocation": "^4.9.3"

`return {
// Debug - REMOVER EM PRODUÇÃO
debug: false,
//logLevel: 5, // VERBOSE

// Configurações básicas - BALANCEADAS PARA BACKGROUND
reset: false,
desiredAccuracy: 10, // MUDANÇA: 10m (balanceado para background)
distanceFilter: 10, // MUDANÇA: 10m (mais sensível para capturar movimento)

// Configurações de atividade - OTIMIZADAS PARA BACKGROUND
isMoving: true,
stopOnStationary: false, // MUDANÇA: false para continuar funcionando em background
stopTimeout: 5, // MUDANÇA: 5 minutos (mais tempo antes de parar)
stationaryRadius: 25, // MUDANÇA: 25m (mais flexível)

// Configurações de background CRÍTICAS PARA FUNCIONAMENTO GARANTIDO
enableHeadless: true, // ESSENCIAL para Android
foregroundService: true,


// CONFIGURAÇÕES CRÍTICAS PARA BACKGROUND
forceReloadOnLocationChange: false,
forceReloadOnMotionChange: false,
forceReloadOnGeofence: false,
forceReloadOnBoot: false,
forceReloadOnHeartbeat: false,

// GARANTIR QUE CONTINUE EM BACKGROUND
pausesLocationUpdatesAutomatically: false, // iOS - não pausar automaticamente
showsBackgroundLocationIndicator: true, // iOS - mostrar indicador

// Android específico para background
notification: {
  title: 'Sister Motorista',
  text: 'Rastreamento de rota ativo',
  color: 'red',
  smallIcon: 'mipmap/ic_launcher',
  largeIcon: 'mipmap/ic_launcher',
  sticky: true,
  priority: 2, // PRIORITY_HIGH
  channelName: 'Sister GPS Tracking',
  actions: [],
  layout: 'default',
  strings: {
    notificationIconColor: '#FF0000',
    notificationTitle: 'Sister Motorista',
    notificationText: 'Rastreamento GPS ativo',
  },
},

// Prevenção de suspensão
preventSuspend: true,
stopOnTerminate: false,
startOnBoot: true,
enableBackgroundLocationUpdates: true, // iOS

// Configurações específicas para resolver ForegroundService timeout
requiredLocationAccuracy: 50,
locationsOrderDirection: 'DESC',
syncThreshold: 5,

// Configurações Android específicas para ForegroundService
enableHighAccuracy: true,
persist: true,
schedule: [],

// Configurações CRÍTICAS para funcionamento em background
stopOnStationary: false, // MUDANÇA: false para continuar em background
startOnBoot: true,
enableTimestampMeta: true,

// NOVAS configurações para garantir background
allowIdenticalLocations: true, // Permitir localizações idênticas em background
maxRecordsToPersist: 1000, // Mais registros para não perder dados

// Configurações específicas do Android
locationAuthorizationAlert: {
  titleWhenInUse: 'Background Location',
  titleWhenOff: 'Location services disabled',
  instructions:
    'To enable background location, tap Settings > Location > Always',
  cancelButton: 'Cancel',
  settingsButton: 'Settings',
},

// Configurações de heartbeat - CRÍTICO PARA BACKGROUND
heartbeatInterval: 30, // MUDANÇA: 30 segundos (mais frequente para manter vivo)

// CONFIGURAÇÕES ADICIONAIS PARA GARANTIR BACKGROUND
enableBackgroundSync: true,
maxCacheSize: 1000,

// Configurações de localização - OTIMIZADAS PARA BACKGROUND
locationUpdateInterval: 5000, // MUDANÇA: 5 segundos (mais frequente em background)
fastestLocationUpdateInterval: 2000, // MUDANÇA: 2 segundos (mais responsivo)
desiredOdometerAccuracy: 30, // MUDANÇA: 30 metros (mais flexível para background)

// NOVOS FILTROS DE QUALIDADE
// Filtrar localizações com baixa precisão
disableLocationAuthorizationAlert: false,
enableTimestampMeta: true,

// Configurações de bateria - MAIS EFICIENTES
disableElasticity: true, // Desabilitar elasticidade para ser mais consistente
elasticityMultiplier: 1,

// Configurações de movimento - BALANCEADAS PARA BACKGROUND
minimumActivityRecognitionConfidence: 70, // MUDANÇA: 70% (mais flexível para background)
disableMotionActivityUpdates: false,

// Configurações adicionais para garantir funcionamento
disableStopDetection: true, // MUDANÇA: true para não parar em background
disableElasticity: false, // MUDANÇA: false para mais flexibilidade
elasticityMultiplier: 2, // MUDANÇA: Aumentar elasticidade

// HTTP Sync
autoSync: true,
autoSyncThreshold: 5,
batchSync: true,
maxDaysToPersist: 1,
maxBatchSize: 50,

// Template da localização
locationTemplate: JSON.stringify({
  age: '<%= age %>',
  uuid: '<%= uuid %>',
  latitude: '<%= latitude %>',
  longitude: '<%= longitude %>',
  created_at_gps: '<%= timestamp %>',
  speed: '<%= speed %>',
  odometer: '<%= odometer %>',
  is_moving: '<%= is_moving %>',
  type: '<%= activity.type %>',
  confidence: '<%= activity.confidence %>',
  level: '<%= battery.level %>',
  is_charging: '<%= battery.is_charging %>',
  mock: '<%= mock %>',
  timestamp: '<%= timestamp %>',
  accuracy: '<%= accuracy %>',
  event: '<%= event %>',
}),

// Dados extras
extras: {
  worked_route_id: routeId,
  status: 0,
},

// Headers HTTP
headers: {
  Authorization: `bearer ${token}`,
},

// URL do servidor
url: `${baseURL}/driver/streaming`,
method: 'POST',

// Configurações Android específicas
locationAuthorizationRequest: 'Always',
backgroundPermissionRationale: {
  title:
    'Permitir {applicationName} para acessar a localização deste dispositivo em segundo plano?',
  message:
    'Para rastrear sua atividade em segundo plano, ative {backgroundPermissionOptionLabel} permissão de localização, mesmo quando o aplicativo está fechado ou não está em uso.',
  positiveAction: 'Mudar para {backgroundPermissionOptionLabel}',
  negativeAction: 'Cancelar',
},

};`

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions