<div dir="ltr">Hi Folks,<div style>As you know we have a Java Sender Library that can be used by any backend application that want to send messages to the Unified Message Push Server (<a href="https://github.com/aerogear/aerogear-unified-push-java-client">https://github.com/aerogear/aerogear-unified-push-java-client</a>).</div>
<div style>The format is quite open and flexible as Matthias described it here : <a href="https://gist.github.com/matzew/b21c1404cc093825f0fb">https://gist.github.com/matzew/b21c1404cc093825f0fb</a><br></div><div style>We can divide the creation of a message in 2 main parts :</div>
<div style><br></div><div style>- The "signalling" part : list of client identifiers / specific devices etc ...</div><div style>- The "core" message containing actually the information we want to push</div>
<div style><br></div><div style>Both are passed as Map and are finally converted into JSON. </div><div style>Here an example of how a "core" message is build :</div><div style><br></div><div style><pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;line-height:19px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(221,221,221);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(0,0,0);margin-top:0px!important">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:normal;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Map categories = new HashMap();
categories.put("lead", "version="+leadVersion++);
Map json = new HashMap();
json.put("id", lead.getId());
json.put("messageType", "pushed_lead");
json.put("name", lead.getName());
json.put("location", lead.getLocation());
json.put("phone", lead.getPhoneNumber());
json.put("simple-push", categories);
json.put("sound" ,"default");
json.put("alert" ,"A new lead has been created");</code></pre></div><div style><br></div><div style>Even the format is open, we could "assist" a bit the developer in building the message. For that we have different options : </div>
<div style>- Propose a simple Message object containing the message "API" :</div><div style><br></div><div style><pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;line-height:19px;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(221,221,221);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(0,0,0)">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:normal;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Message message = new Message();
message.setClientIdentifiers("jake","maria");
message.enableSound();//by default use "default" or we could do message.enableSound("boing")
message.setAlert("Watch out!);
message.setAttribute("customAttribute","yo"); // custom simple strings
message.setAttribute("customStructure",myObject); // passing objects</code></pre></div><div style><br></div><div style>- Propose a Message Builder (following the Builder Pattern) to propose a more fluent API : </div>
<div style><br></div><div style><pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;line-height:19px;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(221,221,221);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(0,0,0)">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:normal;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Message message = new Message().builder()
.clientIdentifiers("jake","maria")
.enableSound()
.alert("AAAAHHH!")
.attribute("customAttribute","yo")
.attribute("customStructure",myObject)
.build()</code></pre></div><div style><br></div><div style>- Same as above but more DSL focused (not sure about this one ;) )</div><div style><pre style="font-size:13px;font-family:Consolas,'Liberation Mono',Courier,monospace;line-height:19px;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(221,221,221);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(0,0,0)">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:normal;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Message message = MessageDSL.to(<span style="background-color:transparent">"jake","maria").withSound() //etc ...</span><br>
<br></code></pre></div><div style><br></div><div style>So, beside that we have to discuss what we want allow to pass to the message API : only Strings and simple Maps ? Full Objects that will be JSONified ? </div><div style>
<br></div><div style>Do we want also to separate the "signalling" part from the "core" part when building a message ? </div><div style><br></div><div style>Inputs and comments more than welcome !</div>
<div style><br></div><div style>Seb</div><div style><br></div></div>