diff --git a/services/tunnelbroker/rust-notifications/src/apns.rs b/services/tunnelbroker/rust-notifications/src/apns.rs --- a/services/tunnelbroker/rust-notifications/src/apns.rs +++ b/services/tunnelbroker/rust-notifications/src/apns.rs @@ -10,7 +10,8 @@ certificate_password: &str, device_token: &str, topic: Option<&str>, - message: &str, + message_text: &str, + message_payload_data: Option<&str>, sandbox: bool, ) -> Result<()> { let mut certificate = File::open(certificate_path)?; @@ -25,8 +26,14 @@ apns_topic: topic, ..Default::default() }; - let builder = PlainNotificationBuilder::new(message); - let payload = builder.build(device_token, options); + let builder = PlainNotificationBuilder::new(message_text); + let mut payload = builder.build(device_token, options); + match message_payload_data { + Some(payload_data) => { + payload.add_custom_data("payload_data", &payload_data)?; + } + None => (), + } let response = client.send(payload).await?; if response.code != 200 { return Err(anyhow!( diff --git a/services/tunnelbroker/rust-notifications/src/lib.rs b/services/tunnelbroker/rust-notifications/src/lib.rs --- a/services/tunnelbroker/rust-notifications/src/lib.rs +++ b/services/tunnelbroker/rust-notifications/src/lib.rs @@ -13,7 +13,8 @@ certificate_password: &str, device_token: &str, topic: &str, - message: &str, + message_text: &str, + message_payload_data: &str, sandbox: bool, ) -> Result<()>; @@ -37,7 +38,8 @@ certificate_password: &str, device_token: &str, topic: &str, - message: &str, + message_text: &str, + message_payload_data: &str, sandbox: bool, ) -> Result<()> { RUNTIME.block_on(apns::send_by_a2_client( @@ -45,7 +47,12 @@ certificate_password, device_token, if topic.is_empty() { None } else { Some(topic) }, - message, + message_text, + if message_payload_data.is_empty() { + None + } else { + Some(message_payload_data) + }, sandbox, )) }