Crates.io | expo-server-sdk |
lib.rs | expo-server-sdk |
version | 0.1.0 |
source | src |
created_at | 2018-07-05 06:08:20.219807 |
updated_at | 2018-07-05 06:08:20.219807 |
description | Server side library for working with Expo using Rust. Includes a client to send push notifications to users of your mobile app using the Expo push notification services. |
homepage | https://docs.expo.io |
repository | https://github.com/expo/expo-server-sdk-rust |
max_upload_size | |
id | 72942 |
size | 21,734 |
The Expo Push Notification client provides a way for you to send push notifications to users of your mobile app using the Expo push notification services. For more details on the Expo push notification service, go [here] (https://docs.expo.io/versions/latest/guides/push-notifications)
extern crate expo_server_sdk;
use expo_server_sdk::*;
use std::str::FromStr;
let token = PushToken::from_str("ExpoPushToken[my-token]").unwrap();
let mut msg = PushMessage::new(token).body("test notification");
let push_notifier = PushNotifier::new().gzip_policy(GzipPolicy::Always);
let result = push_notifier.send_push_notification(&msg);
if let Ok(result) = result {
println!("Push Notification Response: \n \n {:#?}", result);
}
# Send a push notification with a body, passing in the push token
expo-server --body="test notification" ExpoPushToken[my-token]
Receives the response:
Push Notification Response:
PushReceipt {
status: "error",
message: Some(
"\"ExpoPushToken[my-token]\" is not a registered push notification recipient"
),
details: Some(
Object(
{
"error": String(
"DeviceNotRegistered"
)
}
)
)
}