Skip to content

Commit

Permalink
Merge pull request #3 from pimeys/mutable_content
Browse files Browse the repository at this point in the history
Add support for mutable-content
  • Loading branch information
pimeys committed Apr 18, 2017
2 parents f20c0a0 + 9b5ca15 commit daf44c3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/lib.rs
Expand Up @@ -10,7 +10,6 @@
//! `recv_timeout`. The request is handled in another thread and the response is
//! sent through a channel to the thread calling the method.

#[macro_use]
extern crate solicit;
extern crate rustc_serialize;
extern crate time;
Expand Down
25 changes: 25 additions & 0 deletions src/payload.rs
Expand Up @@ -29,6 +29,24 @@ impl Payload {
sound: Some(sound.into()),
content_available: None,
category: category,
mutable_content: false,
},
custom: custom_data,
}
}

pub fn new_mutable<S>(alert: APSLocalizedAlert, sound: S, badge: Option<u32>, category: Option<String>,
custom_data: Option<CustomData>) -> Payload
where S: Into<String>
{
Payload {
aps: APS {
alert: Some(APSAlert::Localized(alert)),
badge: badge,
sound: Some(sound.into()),
content_available: None,
category: category,
mutable_content: true,
},
custom: custom_data,
}
Expand All @@ -42,6 +60,7 @@ impl Payload {
sound: None,
content_available: Some(1),
category: None,
mutable_content: false,
},
custom: custom_data,
}
Expand Down Expand Up @@ -90,6 +109,9 @@ pub struct APS {

/// Provide this key with a string value that represents the identifier property.
pub category: Option<String>,

/// Can the client modify the alert before showing it to the user
pub mutable_content: bool,
}

impl ToJson for APS {
Expand All @@ -116,6 +138,9 @@ impl ToJson for APS {
if let Some(ref category) = self.category {
d.insert("category".to_string(), category.to_json());
}
if self.mutable_content {
d.insert("mutable-content".to_string(), 1.to_json());
}
Json::Object(d)
}
}
Expand Down

0 comments on commit daf44c3

Please sign in to comment.