jpush 0.4.0

集成极光App推送
Documentation
#[cfg(test)]
mod tests {
    use jpush::client::JPushClient;
    use jpush::config::JPushConfig;
    use jpush::msg::{JPushMessage, MessageOptions, ThirdPartyChannel, ThirdPartyChannelContent};

    #[tokio::test]
    async fn push() {
        let config = JPushConfig {
            url: "https://api.jpush.cn/v3/push".to_string(),
            app_key: "2ce8e178e4826f317384a085".to_string(),
            secret: "c45634140c0ee85b86552c75".to_string(),
        };
        let client = JPushClient::new(config);
        let mut msg = JPushMessage::simple_normal_message("TS订单通知","TS 您有新的订单通知,请前往App查看!", "WORK");
        let mut third_party_channel = ThirdPartyChannel::from_category("WORK");
        third_party_channel.xiaomi = Some(ThirdPartyChannelContent {
            distribution: Some("secondary_push".to_string()),
            distribution_fcm: Some("secondary_fcm_push".to_string()),
            category: Some("WORK".to_string()),
            channel_id: Some("138397".to_string()),
            importance: Some("NORMAL".to_string()),
            skip_quota: Some(true),
            ..Default::default()
        });
        third_party_channel.vivo = Some(ThirdPartyChannelContent {
            category: Some("ORDER".to_string()),
            classification: Some(1),
            skip_quota: Some(true),
            ..Default::default()
        });
        third_party_channel.oppo = Some(ThirdPartyChannelContent {
            category: Some("ORDER".to_string()),
            channel_id: Some("order".to_string()),
            skip_quota: Some(true),
            ..Default::default()
        });
        let mut options = MessageOptions::from_category("WORK");
        options.third_party_channel = Some(third_party_channel);
        msg.set_options(options);

        msg.add_alias(vec![
            "1135".to_string(),
        ]);
        print!("Message: \n {}", serde_json::to_string(&msg).unwrap());
        let res = client.send(msg).await.unwrap();
        println!("\n");
        println!("res: {:?}", res);
    }
}