}, function(){

      date = getDate();

      const address = 'https://cheeseboardapi.herokuapp.com/api/today/' + date;

      fetch(address)
        .then((response) => response.json())
        .then((responseData) => {
          var pizza = '';
          if (responseData.length < 1){
            PushNotification.localNotification({
              message: "No good pizza today",
              number: 0
            });
          } else {
            pizza = responseData[0].pizza_type;
            const pizzaCheck = pizza.toLowerCase();
            for (var i = 0; i < alerts.length; i++) {
              if (pizzaCheck.includes(alerts[i].toLowerCase())){
                console.log("Time to get pizza!");
                PushNotification.localNotification({
                  message: pizza,
                  number: 0
                });

                i = alerts.length;
              } 
            }
          }

        })
        .catch(function(error){
          console.log(error);
        });

      BackgroundFetch.finish();
    }, function(error){
Exemplo n.º 2
0
 }, function() {
   SimpleStore.save('background fetch success', {
     success: new Date(),
   });
   BackgroundFetch.finish();
 }, function(error) {