Struct gcm::Message [] [src]

pub struct Message<'a> { /* fields omitted */ }

Represents a GCM message. Construct the GCM message using various utility methods and finally send it.

Examples:

use gcm::Message;
 
let message = Message::new("<registration id>").dry_run(true);

Methods

impl<'a> Message<'a>
[src]

Get a new instance of Message. You need to supply either a registration id, or a topic (/topic/...).

Set various registration ids to which the message ought to be sent.

Set this parameter to identify groups of messages that can be collapsed.

Set the priority of the message. You can set Normal or High priorities.

Examples:

use gcm::{Message, Priority};
 
let message = Message::new("<registration id>")
    .priority(Priority::High);

To set the content-available field on iOS

When set to true, sends the message only when the device is active.

How long (in seconds) to keep the message on GCM servers in case the device is offline. The maximum and default is 4 weeks.

Package name of the application where the registration tokens must match.

When set to true, allows you to test GCM without actually sending the message.

Use this to add custom key-value pairs to the message. This data must be handled appropriately on the client end.

Examples:

use gcm::Message;
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert("message", "Howdy!");
 
let message = Message::new("<registration id>").data(map);

Use this to set a Notification for the message.

Examples:

use gcm::{Message, NotificationBuilder};

let notification = NotificationBuilder::new("Hey!")
    .body("Do you want to catch up later?")
    .finalize();
 
let message = Message::new("<registration id>")
    .notification(notification);

Send the message using your GCM API Key.

Examples:

use gcm::Message;
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert("message", "Howdy!");
 
let result = Message::new("<registration id>")
    .data(map)
    .send("<GCM API Key>");