<div dir="ltr"><p style="margin-right:0px;margin-bottom:15px;margin-left:0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px;margin-top:0px!important">Hi,</p>
<p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">as you know the unified push server has a &#39;registration&#39; component (see <a href="https://gist.github.com/matzew/69d33a18d4fac9fdedd4" style="color:rgb(65,131,196);text-decoration:none">here</a> for details; see <a href="https://gist.github.com/matzew/2da6fc349a4aaf629bce" style="color:rgb(65,131,196);text-decoration:none">here</a> for REST APIs) which does the following:</p>
<ul style="margin:15px 0px;padding:0px 0px 0px 30px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px"><li>app registration and adding multiple variations</li>
<li>registration of an installation, submitted from the device</li></ul><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">There are different roles (as also discussed in the above links).... The &quot;app registration&quot; functionality can be only achieved by something <em>like</em> an &quot;admin&quot;;</p>
<p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">The admin can create a logical app construct on the server ( <em>Sport News mobile</em> ), which has different variations:</p>
<ul style="margin:15px 0px;padding:0px 0px 0px 30px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px"><li>free for iOS/Android (no user required, everybody can install the app)</li>
<li>paid (same, for both: iOS/Android): User is required, since they pay for extra, exclusive content</li></ul><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">
Now.... the &quot;logical&quot; app construct on the server get&#39;s some ID, when the app has been registered... (similar for each of the variants: iOS/iOS-paid etc...)</p><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">
This part of the registration needs to be protected, very well (e.g. OAuth); just thinking out loud.... But yeah... only users, with the proper rights should be able to register (update/delete) apps here!!!</p><h3 style="margin:20px 0px 10px;padding:0px;font-size:18px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif">
<a name="deviceinstallation-registration" class="" href="https://gist.github.com/matzew/e335881b3f95b1448774#deviceinstallation-registration" style="color:rgb(65,131,196);text-decoration:none;display:block;padding-left:30px"></a>Device/Installation registration</h3>
<p style="margin:0px 0px 15px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">However, the other part of the registration (when an installation, from a device, tries to register itself for wanting to receive messages), may be a little more &quot;weak&quot;...</p>
<p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">Scenario:</p><ul style="margin:15px 0px;padding:0px 0px 0px 30px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">
<li>Someone downloads the free iOS app:</li><li>once he launches the app and he agrees on receiving push messages</li><li>Now... the app should send the generated token (generated by the actual Push Network), to the registration server... (otherwise it can&#39;t receive push messages :-) ).</li>
</ul><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">So...... the following information needs to be available.... so that the mobile dev. for the free iOS app can register the token with the server:</p>
<ul style="margin:15px 0px;padding:0px 0px 0px 30px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px"><li>APP ID (+ mobile-variant ID)</li></ul><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">
Yes, the IDs are needed.... in order to tell the &quot;registration server&quot;: <em>Hey, this installation for XYZ wants to receive messages.....</em></p><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">
So, the iOS (client SDK) code could look like:</p><div class="" style="border:0px;padding:0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px"><pre style="font-size:13px;line-height:19px;font-family:Consolas,&#39;Liberation Mono&#39;,Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);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">
<span class="" style="font-weight:bold">-</span> <span class="">(</span><span class="" style="color:rgb(68,85,136);font-weight:bold">void</span><span class="">)</span><span class="" style="color:rgb(153,0,0);font-weight:bold">application:</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">UIApplication</span> <span class="" style="font-weight:bold">*</span><span class="">)</span><span class="" style="color:teal">application</span>
<span class="">didRegisterForRemoteNotificationsWithDeviceToken:</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">NSData</span> <span class="" style="font-weight:bold">*</span><span class="">)</span><span class="" style="color:teal">deviceToken</span>
<span class="">{</span>
    <span class="" style="color:rgb(51,51,51)">NSURL</span> <span class="" style="font-weight:bold">*</span><span class="" style="color:rgb(51,51,51)">serverURL</span> <span class="" style="font-weight:bold">=</span> <span class="">[</span><span class="" style="color:rgb(51,51,51)">NSURL</span> <span class="" style="color:rgb(51,51,51)">URLWithString</span><span class="" style="font-weight:bold">:</span><span class="" style="color:rgb(221,17,68)">@&quot;<a href="http://pusher.server.com/registry/device/">http://pusher.server.com/registry/device/</a>&quot;</span><span class="">];</span>

    <span class="" style="color:rgb(51,51,51)">PushClient</span> <span class="" style="font-weight:bold">*</span><span class="" style="color:rgb(51,51,51)">pclient</span> <span class="" style="font-weight:bold">=</span> <span class="">[</span><span class="" style="color:rgb(51,51,51)">PushClient</span> <span class="" style="color:rgb(51,51,51)">appID</span><span class="" style="font-weight:bold">:</span><span class="" style="color:rgb(221,17,68)">@&quot;1234&quot;</span> <span class="" style="color:rgb(51,51,51)">mobileID</span><span class="" style="font-weight:bold">:</span><span class="" style="color:rgb(221,17,68)">@&quot;456454&quot;</span><span class="">];</span>
    <span class="">[</span><span class="" style="color:rgb(51,51,51)">pclient</span> <span class="" style="color:rgb(51,51,51)">registerDeviceToken</span><span class="" style="font-weight:bold">:</span><span class="" style="color:rgb(51,51,51)">deviceToken</span> <span class="" style="color:rgb(51,51,51)">withServer</span><span class="" style="font-weight:bold">:</span><span class="" style="color:rgb(51,51,51)">serverURL</span> <span class="" style="color:rgb(51,51,51)">success</span><span class="" style="font-weight:bold">:^</span><span class="">(</span><span class="" style="color:rgb(68,85,136);font-weight:bold">id</span> <span class="" style="color:rgb(51,51,51)">responseObject</span><span class="">)</span> <span class="">{</span>
        <span class="" style="color:rgb(51,51,51)">NSLog</span><span class="">(</span><span class="" style="color:rgb(221,17,68)">@&quot;Registration Success: %@&quot;</span><span class="">,</span> <span class="" style="color:rgb(51,51,51)">responseObject</span><span class="">);</span>
    <span class="">}</span> <span class="" style="color:rgb(51,51,51)">failure</span><span class="" style="font-weight:bold">:^</span><span class="">(</span><span class="" style="color:rgb(51,51,51)">NSError</span> <span class="" style="font-weight:bold">*</span><span class="" style="color:rgb(51,51,51)">error</span><span class="">)</span> <span class="">{</span>
        <span class="" style="color:rgb(51,51,51)">NSLog</span><span class="">(</span><span class="" style="color:rgb(221,17,68)">@&quot;Registration Error: %@&quot;</span><span class="">,</span> <span class="" style="color:rgb(51,51,51)">error</span><span class="">);</span>
    <span class="">}];</span>
<span class="">}</span>
</pre></div><p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">The code above would be used by some customer/user, when they register their app with their running version, of our Unified Push server..... Not sure.... are we concerned about the keys are compiled into the actual app, that everybody could download from the app store ?</p>
<p style="margin:15px 0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px">We really can&#39;t issue a login in the above case, since there may be no user..... and even if the paid app, requires a user..... someone can still first buy the app, and after installation decide to register a new user, from the app...... so the above code is still executed BEFORE the user decides to active/register his account...</p>
<p style="margin-top:15px;margin-right:0px;margin-left:0px;color:rgb(0,0,0);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13.63636302947998px;line-height:20px;margin-bottom:0px!important">Matthias</p><div>
<br></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>