final List<String> registrationIDs = new ArrayList<String>(tokens);
final AndroidVariant androidVariant = (AndroidVariant) variant;
// payload builder:
Builder gcmBuilder = new Message.Builder();
org.jboss.aerogear.unifiedpush.message.Message message = pushMessage.getMessage();
// add the "recognized" keys...
gcmBuilder.addData("alert", message.getAlert());
gcmBuilder.addData("sound", message.getSound());
gcmBuilder.addData("badge", "" + message.getBadge());
// if present, apply the time-to-live metadata:
int ttl = pushMessage.getConfig().getTimeToLive();
if (ttl != -1) {
gcmBuilder.timeToLive(ttl);
}
// iterate over the missing keys:
Set<String> keys = message.getUserData().keySet();
for (String key : keys) {
// GCM needs stringified values:
gcmBuilder.addData(key, "" + message.getUserData().get(key));
}
Message gcmMessage = gcmBuilder.build();
// send it out.....
try {
logger.fine("Sending transformed GCM payload: " + gcmMessage);