Internet of Things
TinkerforgeCode in ActionAbout Me
  • Course Outline
  • 1 - Getting Started
    • Overview
    • Connect to the LED
    • Getting Started
      • Glitch
      • The Application Template
    • Concepts in Programming
      • What is Programming?
      • Variables
      • Functions and Commands
      • Control Structures
      • Loops
      • Objects and Libraries
    • Programming Simple Web Apps
    • Exercises
      • 1.1 Buttons and Inputs
  • 2 - Internet of Things
    • Overview
    • IoT in our Apps
      • Getting Started
        • Hardware Kit
        • Brick Viewer and Daemon
      • Connect to the Devices
        • The Tinkerforge Device Manager
      • Program the Devices
        • RGB LED
        • RGB LED Button
        • OLED Display
        • Sensors
          • Humidity Sensor
          • Ambient Light Sensor
    • Components and Use Cases
    • Exercises
      • 2.1 Lights and Buttons
      • 2.2 Sensors
      • 2.3 Display
  • 3 - Artificial Intelligence
    • Overview
    • AI in our Apps
      • Google's Teachable Machine
      • Face Recognition
      • Training a Custom Model
    • Rules vs. Learning
    • Learning from Data
    • Use Cases
      • Computer Vision
        • Image Classification
        • Handwriting Recognition
    • Machine Learning Algorithms
      • Artificial Neural Networks
      • Decision Trees
      • Logistic Regression
    • Exercises
      • 3.1 Rules vs. Learning
      • 3.2 Fruits and Vegetables
      • 3.3 Face Recognition
      • 3.4 A Classifier for Iris
  • 4 - Cloud & APIs
    • Overview
    • APIs in our Apps
    • Cloud and APIs
      • Weather API
      • NASA Open APIs
      • EDAMAM Nutrition and Recipes API
    • Push Notifications
    • Exercises
  • 5 - App Project
    • Overview
    • Summer 2021
    • Summer 2022
  • Appendix
    • Other Devices
      • Motorized Linear Poti
      • Sound Pressure Sensor
      • NFC Reader
      • Motion Detector
    • UI Features
      • Realtime Charts
      • Countdown Timer
    • Digital Computers
      • Overview
      • The Binary System
      • Code Systems
      • Logic Gates
      • Binary Addition
      • From Analog to Digital
    • Cheat Sheets
    • Projects
      • IoT @ Pickup-Boxes
Powered by GitBook
On this page
  • Video
  • Enable webhooks service
  • Create a new applet
  • Trigger the webhook from our app
  • Links

Was this helpful?

  1. 4 - Cloud & APIs

Push Notifications

Sometimes it is useful to alert a user in real-time on their smartphone. In this case, we can use push messages with IFTTT and web hooks. This tutorial explains how.

PreviousEDAMAM Nutrition and Recipes APINextExercises

Last updated 4 years ago

Was this helpful?

Video

Watch this video where I walk you through the process of setting up and integrate it with our JavaScript code:

Enable webhooks service

Type "webhook" into the search field in the upper-left corner and hit enter. In the results, click on the services tab and click on the box with the label "Webhooks".

In the opening page, you should a "settings" symbol in the upper-right corner. Click this symbol to activate or deactivate your webhook-URL. Copy the URL into your browser to open the documentation page.

Create a new applet

Trigger the webhook from our app

You can copy the following function to call your IFTTT webhook from JavaScript. The function uses the fetch() function to make an HTTP POST request to the URL specified in the IFTTT documentation. The function expects you to pass your personal key and the event name that should be sent. Additionally, you can pass 3 possible parameter values to provide more information.

function sendIFTTTPushNotification(
  eventName,
  key,
  value1 = null,
  value2 = null,
  value3 = null
) {
  var url =
    "https://maker.ifttt.com/trigger/" +
    eventName +
    "/with/key/" +
    key +
    "?value1=" +
    value1 +
    "&value2=" +
    value2 +
    "&value3=" +
    value3;

  fetch(url, {
    method: "post",
    mode: "no-cors",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json"
    }
  }).then(response => {
    console.log(
      "IFTTT webhook called successfully. See if there were errors before."
    );
    return true;
  });
}

Links

Navigate to the within IFTTT. You should see the following image:

page where you can create a new applet
IFTTT
IFTTTIFTTT
Logo
IFTTT applets are based on a trigger and an action.