Nustify

crates.io Documentation

💬 Send iOS/Android notifications using IFTTT's Webhook 💬

nustify = "0.2"

IFTTT

From Wikipedia:

IFTTT is a free web-based service to create chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Telegram, Instagram, or Pinterest.

IFTTT proposes hundreds of triggers, but the one that Notigo uses is the Webhook trigger (also known as Maker Event).

By creating an IFTTT applet that sends a rich notification to your device when a Webhook is triggered, we can create a simple wrapper and use it in our Rust code.

IFTTT account and mobile app

In order to receive a notification from IFTTT, you have to create an IFTTT account and download the iOS app or the Android app.

Creating the IFTTT applet

Next, you need to create the corresponding applet in your IFTTT account. Applets that use Webhook as a trigger can't be share like other applets, so you need to create it manually:

The final configuration of the applet looks like this:

Screen Shot 2021-04-26 at 00 54 32 Screen Shot 2021-04-26 at 00 55 54

Getting the Webhook key

The last step before using the applet is to get your Webhook key. Head to the Webhook settings page then click on the Documentation button on the upper right corner.

Now that you have created the applet and got your Webhook key, you can use the library or the example command.

Using the library

Here is a simple example that send a notification with "Hello from Rust" as a title and "Rusty content" as a message:

```rust use std::error::Error; use nustify::notification::Builder;

[tokio::main(flavor = "current_thread")]

async fn main() -> Result<(), Box> { let key = "MYIFTTTKEY"; let notification = Builder::new("Rusty content".toowned()) .title("Hello from Rust".toowned()) .build(); nustify::send(&notification, "nustify", &key).await?; Ok(()) } ```

Sending images

If you want to add an image to your notification, you have to pass its link rather than the image data itself. This library also provides a wrapper to the Imgur API allowing you to first upload the image to Imgur.

Golang version

I also released a Golang version of this library and a command.

Enjoy simple notifications!