Skip to content

Job not triggered #169

@luizgallas

Description

@luizgallas

What am I doing wrong? This is not inside a component. I want to push a notification everytime the interval set by the user is reached.

export default function scheduleRoutine(routine) {
  const message = routine.message === '' ? 'Lembrete automático' : routine.message;

  BackgroundJob.register({
    jobKey: routine.cod.toString(),
    job: () => {
      if (validateSchedule(routine)) {
        PushNotification.localNotification({
          title: `Sua rotina: ${routine.name}`,
          message: message,
          vibration: 900,
          invokeApp: true,
          date: new Date(Date.now() + routine.interval * 60000),
          id: JSON.stringify(routine.cod),
          userInfo: {id: JSON.stringify(routine.cod)},
        });
        cancelNotification(routine);
      };
    }
  });
  console.log('Registered Job: ', routine.cod);

  BackgroundJob.schedule({
    jobKey: routine.cod.toString(),
    period: routine.interval * 60000,
    exact: true,
    allowWhileIdle: true,
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions