<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 24, 2014 at 7:14 PM, Matthias Wessendorf <span dir="ltr"><<a href="mailto:matzew@apache.org" target="_blank">matzew@apache.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">
<div class="">On Mon, Feb 24, 2014 at 6:36 PM, Miguel Lemos <span dir="ltr"><<a href="mailto:miguel21op@gmail.com" target="_blank">miguel21op@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">That would be neat if I understand a simple way to send a push to a particular dude's phone. So far I've not yet understood how... <br>
</div></blockquote><div><br></div><div><span style="line-height:23.18181800842285px;font-size:15.454545021057129px;font-family:Helvetica,arial,freesans,clean,sans-serif"><br></span></div></div><div><span style="line-height:23.18181800842285px;font-size:15.454545021057129px;font-family:Helvetica,arial,freesans,clean,sans-serif">use an alias that is </span><em style="line-height:23.18181800842285px;font-size:15.454545021057129px;font-family:Helvetica,arial,freesans,clean,sans-serif">unique</em><span style="line-height:23.18181800842285px;font-size:15.454545021057129px;font-family:Helvetica,arial,freesans,clean,sans-serif"> </span><span style="line-height:23.18181800842285px;font-size:15.454545021057129px;font-family:Helvetica,arial,freesans,clean,sans-serif">(E.g. the user-id in your backend):</span><br>
</div><div><pre style="background-color:rgb(248,248,248);border-top-left-radius:3px;margin-bottom:15px;padding:6px 10px;line-height:19px;border-top-right-radius:3px;font-size:13px;overflow:auto;border-bottom-right-radius:3px;font-family:Consolas,'Liberation Mono',Courier,monospace;word-wrap:normal;margin-top:15px;border:1px solid rgb(221,221,221);border-bottom-left-radius:3px">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:inherit;margin: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;display:inline;vertical-align:middle;padding:0px;word-wrap:normal">curl -3 -u "{variantID}:{secret}"
-v -H "Accept: application/json" -H "Content-type: application/json"
-X POST
-d '{
"deviceToken" : "someTokenString",
"alias" : "myUniqueString"
}'
https://SERVER:PORT/context/rest/registry/device
</code></pre><p style="line-height:23.18181800842285px;font-size:15.454545021057129px;font-family:Helvetica,arial,freesans,clean,sans-serif;margin:15px 0px">Now, the above does store this string (the <code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:1.3;margin:0px;border:1px solid rgb(221,221,221);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;max-width:100%;display:inline-block;overflow:auto;vertical-align:middle;padding:0px;white-space:nowrap">alias</code> <span style="font-size:15.454545021057129px">) on the device metadata.</span></p>
</div></div></div></div></blockquote><div><br></div><div><br></div><div><br></div><div><br></div><div><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:15.454545021057129px;line-height:23.18181800842285px">
Oh, since you are using Cordova, I translated the generic curl (from our REST API doc) to JavaScript:</p><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;word-wrap:normal;color:rgb(0,0,0)">
<code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:inherit;margin: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;display:inline;vertical-align:middle;padding:0px;word-wrap:normal">var pushConfig = {
// senderID is only used in the Android/GCM case
senderID: "<senderID e.g Google Project ID only for android>",
pushServerURL: "<pushServerURL e.g http(s)//host:port/context >",
variantID: "<variantID e.g. 1234456-234320>",
variantSecret: "<variantSecret e.g. 1234456-234320>",
alias: "myUniqueString" // NOTE!! this must be unique to the user. Do not hard-code that string ;)
// Recommendation is: username;
// the user logins to your backend system. After a successful login you should know the username, which can than
// be used when the 'JavaScript' for the device registration is being executed;
}
//badge and sound are iOS specific, and ignored on Android
push.register(successHandler, errorHandler, {"badge": "true", "sound": "true",
"ecb": "onNotification", pushConfig: pushConfig});
</code></pre></div><div><br></div><div><br></div><div><br></div><div><br></div></div>-- <br>Matthias Wessendorf <br><br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>
sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>
</div></div>