4 releases
new 0.3.0 | Apr 17, 2025 |
---|---|
0.1.5 | Apr 10, 2025 |
0.1.4 | Apr 10, 2025 |
0.1.3 | Nov 5, 2024 |
#282 in Audio
339 downloads per month
54KB
844 lines
JPush for Rust
App Push SDK for Rust
config toml
[jpush]
url = "https://api.jpush.cn/v3/push"
app_key = "your app key"
secret = "your secret"
use demo
use jpush::JPushClient;
use jpush::config::JPushConfig;
use jpush::msg::{JPushMessage, AndroidNotification, HarmonyOSNotification, IosNotification, Message, Platform, PlatformType};
async fn push() {
let config = JPushConfig {
url: "https://api.jpush.cn/v3/push".to_string(),
app_key: "your app key".to_string(),
secret: "your secret".to_string(),
};
let client = JPushClient::new(config);
let mut msg = JPushMessage::simple_normal_message("TS订单通知","TS 订单通知内容,请前往App查看!", "WORK");
msg.add_alias(vec!["1355".to_string(), "1356".to_string()]);
println!("{:?}", message);
let res = client.send(message).await;
match res {
Ok(res) => {
println!("{:?}", res)
}
Err(e) => {
println!("{}", e)
}
}
}
depends on spring-rs use demo
[dependencies]
jpush = { version = "0.3", features = ["spring-rs"] }
use jpush::JPushPlugin;
use jpush::client::JPushClient;
use jpush::msg::{JPushMessage, AndroidNotification, HarmonyOSNotification, IosNotification, Message, Platform, PlatformType};
use spring::App;
#[tokio::main]
async fn main() {
App::new()
.use_config_file("./config/job.toml")
.add_plugin(JPushPlugin)
.run()
.await;
}
async fn push(Component(client): Component<JPushClient>) -> Result<(), Box<dyn std::error::Error>> {
let mut msg = JPushMessage::simple_normal_message("TS订单通知", "TS 订单通知内容,请前往App查看!", "WORK");
msg.add_alias(vec!["1355".to_string(), "1356".to_string()]);
println!("{:?}", message);
let res = client.send(message).await;
match res {
Ok(res) => {
println!("{:?}", res)
}
Err(e) => {
println!("{}", e)
}
}
}
Dependencies
~4–18MB
~231K SLoC