10 releases

0.3.3 Apr 8, 2024
0.3.2 Apr 7, 2024
0.3.1 Mar 31, 2024
0.2.6 Mar 27, 2024
0.1.0 Dec 25, 2023

#6 in #push

Download history 13/week @ 2024-01-19 4/week @ 2024-02-02 146/week @ 2024-02-16 37/week @ 2024-02-23 7/week @ 2024-03-01 90/week @ 2024-03-08 9/week @ 2024-03-15 187/week @ 2024-03-22 316/week @ 2024-03-29 258/week @ 2024-04-05 19/week @ 2024-04-12

780 downloads per month

MIT/Apache

56KB
1.5K SLoC

Expo Push Notification Client for Rust

This is an official Expo Push Notification Client for Rust.

ci crates.io docs.rs license

Client (ReactNative with Expo)

You need to get Expo Push Token from Expo SDK and send it to Expo server first. See docs for more details.

Server (Rust)

Install

cargo add expo_push_notification_client

Usage

use expo_push_notification_client::{Expo, ExpoClientOptions, ExpoPushMessage, GetPushNotificationReceiptsRequest};

// Initialize Expo client
let expo = Expo::new(ExpoClientOptions {
    access_token: Some(access_token),
    use_fcm_v1: Some(false), // Set to true to use FCM v1 API
});

// Define Expo Push Tokens to send notifications to
let expo_push_tokens = ["ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]"];

// Build Expo Push Message with specified tokens
let expo_push_message = ExpoPushMessage::builder(expo_push_tokens).build()?;

// Send push notifications using Expo client
expo.send_push_notifications(expo_push_message).await;

// Define push notification IDs to retrieve receipts
let expo_push_ids = GetPushNotificationReceiptsRequest::new(vec!["xxxxx".to_string(), "xxxxx".to_string()]);

// Retrieve push notification receipts using Expo client
expo.get_push_notification_receipts(expo_push_ids).await;

Additionally, you can further customize the ExpoPushMessage by adding more options. Refer to the docs for more details.

// Build Expo Push Message with detailed configurations
let expo_push_message = ExpoPushMessage::builder(["ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]"])
    .body("body")
    .data(&[("data".to_string())])?
    .ttl(100)
    .expiration(100)
    .priority("high")
    .subtitle("subtitle")
    .sound("default")
    .badge(1)
    .channel_id("channel_id")
    .category_id("category_id")
    .mutable_content(true)
    .title("title")
    .build()?;

Dependencies

~9–22MB
~331K SLoC