title: Expo background fetch initialize but never running
body: <p>While developping my react native app, I need to do a periodic background fetch to another server.
  So I import 2 class from expo :</p>
  <pre class="lang-js prettyprint-override"><code>import * as BackgroundFetch from 'expo-background-fetch';
  import * as TaskManager from 'expo-task-manager';
  </code></pre>
  <p>and initialize my background task :</p>
  <pre class="lang-js prettyprint-override"><code>const fetchFunc = async () =&gt; {
      try{
          console.log(&quot;Hi from fetch function !&quot;)
          return BackgroundFetch.BackgroundFetchResult.NoData;
      }
      catch(err)
      {
          return BackgroundFetch.BackgroundFetchResult.Failed;
      }
  }
  </code></pre>
  <p>Register this task :</p>
  <pre class="lang-js prettyprint-override"><code>async function registerBackgroundFetchAsync() {
      try{
          await BackgroundFetch.registerTaskAsync(&quot;func-fetch&quot;, {
              minimumInterval: 5, // 5 second
          })
          console.log(&quot;background fetch enabled&quot;)
      }
      catch(err){
          console.error(err);
      }
  }
  </code></pre>
  <p>and create a function to execute all of them :</p>
  <pre class="lang-js prettyprint-override"><code>async function initBackgroundFetch() {
      if(!TaskManager.isTaskDefined(&quot;func-fetch&quot;)){
          TaskManager.defineTask(&quot;func-fetch&quot;, fetchFunc)
      }
  
      await registerBackgroundFetchAsync();
  }
  </code></pre>
  <p>Now, I try to launch it when my component is mounted (I use class and typescript) :</p>
  <pre class="lang-js prettyprint-override"><code>class MainPage extends Component
  {
      componentDidMount() {
          initBackgroundFetch();
      }
      .
      .
      .
  
  }
  </code></pre>
  <p>But in my console output I just got the &quot;background fetch enabled&quot; from the registration...
  I think that my initBackgroundFetch is in the wrong place, but can't find where I need to put it.</p>
  <p>PS : my expo diagnostics</p>
  <pre><code>Expo CLI 5.0.3 environment info:
  System:
    OS: Linux 5.15 Kali GNU/Linux Rolling 2021.4
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    npm: 8.1.0 - ~/.nvm/versions/node/v14.16.1/bin/npm
  npmPackages:
    expo: ^43.0.3 =&gt; 43.0.3 
    react: 17.0.1 =&gt; 17.0.1 
    react-dom: 17.0.1 =&gt; 17.0.1 
    react-native: 0.64.3 =&gt; 0.64.3 
    react-native-web: 0.17.1 =&gt; 0.17.1 
  npmGlobalPackages:
    expo-cli: 5.0.3
  Expo Workflow: managed
  </code></pre>