title: Background service in React Native
body: <p>I'm using Firebase, while my app is in the background and i want to when the database has new data, the notification will be pushed, like this:</p>
  
  <pre><code>message.on('child_added', function(data) {
    pushNotification(data);
  });
  </code></pre>
  
  <p>I have searched on Google and found this library:
  <a href="https://github.com/vikeri/react-native-background-job" rel="nofollow noreferrer">https://github.com/vikeri/react-native-background-job</a>.</p>
  
  <p>Everything works fine, my background job:</p>
  
  <pre><code>const newMessageJob = {
     jobKey: "newMessageJob",
     job: () =&gt; {
       pushNotification(newMessage);
     }
  };
  BackgroundJob.register(backgroundJob);
  </code></pre>
  
  <p>But the problem is here, it's only called at fixed times (looks like setInterval): </p>
  
  <pre><code>BackgroundJob.schedule({
    jobKey: "newMessageJob",
    period: 1000,
    timeout: 1000,
    exact: true
  });
  </code></pre>
  
  <p>But i want it to work dynamically (Background Job fired when new data has been added), so how can i solve this problem?</p>
  
  <p>Thanks.</p>