pushinator

Crates.iopushinator
lib.rspushinator
version0.1.3
created_at2025-01-06 13:05:43.58335+00
updated_at2025-01-27 20:24:28.791102+00
description🔔 🦀 A Rust crate for sending push notifications to your devices
homepagehttps://pushinator.com
repositoryhttps://github.com/appricos/pushinator-rust
max_upload_size
id1505564
size49,261
Maks Tamoian (makstamoian)

documentation

README

pushinator-rust

A Rust library that enables developers to send push notifications seamlessly through the Pushinator API, supporting both synchronous and asynchronous operations.

Installation

Add this to your Cargo.toml:

[dependencies]
pushinator = "0.1.2"

Usage

Creating a Client

Creating a client requires you to have a valid Pushinator API token:

use pushinator::PushinatorClient;

fn main() {
    let pushinator_client = PushinatorClient::new("PUSHINATOR_API_TOKEN".to_string());
}

Sending Notifications

Synchronous Method

fn main() {
    let pushinator_client = PushinatorClient::new("PUSHINATOR_API_TOKEN".to_string());

    match pushinator_client.send_notification_sync("PUSHINATOR_CHANNEL_ID".to_string(), "Pushinator from Rust!") {
        Ok(_) => println!("Notification sent successfully!"),
        Err(err) => eprintln!("Error sending notification: {}", err),
    }
}

Asynchronous Method

#[tokio::main]
async fn main() {
    let pushinator_client = PushinatorClient::new("PUSHINATOR_API_TOKEN".to_string());

    match pushinator_client.send_notification("PUSHINATOR_CHANNEL_ID".to_string(), "Pushinator from Rust!").await {
        Ok(_) => println!("Notification sent successfully!"),
        Err(err) => eprintln!("Error sending notification: {}", err),
    }
}

Steps to Get Started

  1. Create a Pushinator account
  2. Set up a notification channel and save the Channel ID and API token
  3. Download the app from the App Store or Google Play to all devices you want to get notifications on
  4. Use the QR code in the dashboard to subscribe your devices to the channel
  5. Use the examples above to set up and trigger notifications
Commit count: 22

cargo fmt