Crates.io | nustify |
lib.rs | nustify |
version | 0.2.2 |
source | src |
created_at | 2021-03-13 00:52:00.917912 |
updated_at | 2021-04-26 00:57:53.431787 |
description | Send iOS/Android Notifications using IFTTT's Webhook |
homepage | https://github.com/scotow/nustify |
repository | |
max_upload_size | |
id | 368071 |
size | 54,562 |
💬 Send iOS/Android notifications using IFTTT's Webhook 💬
nustify = "0.2"
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.
In order to receive a notification from IFTTT, you have to create an IFTTT account and download the iOS app or the Android app.
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:
webhook
and select the Receive a web request
trigger;Create trigger
;that
action, search for notification
and select the Send a rich notification from the IFTTT app
action;Add ingredient
button to add value1
as a title and value2
as a message. value3
as a link or image URL.The final configuration of the applet looks like this:
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.
Here is a simple example that send a notification with "Hello from Rust" as a title and "Rusty content" as a message:
use std::error::Error;
use nustify::notification::Builder;
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn Error>> {
let key = "MY_IFTTT_KEY";
let notification = Builder::new("Rusty content".to_owned())
.title("Hello from Rust".to_owned())
.build();
nustify::send(¬ification, "nustify", &key).await?;
Ok(())
}
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.
I also released a Golang version of this library and a command.
Enjoy simple notifications!