9 Replies Latest reply on Apr 24, 2013 8:37 AM by Justin Bay

    Push Notifications in RhoElements



      I need to figure out a way to set up something like push notifications within RhoElements on Motorola Android devices. It would be great if the notifications could wake up a sleeping device. I see there's a push API in RhoElements, but there's not much talk about what can drive it. Does the API only work with RhoConnect? We'd be looking at driving pushes from a WCF service if at all possible.





        • Re: Push Notifications in RhoElements
          Robert Galvin

          Hi Justin


          The Push API in RhoElements essentially allows you to send http messages to the application (as long as the application is running). Think of it as a web server is listening on a certain port that your application can hook into for notifications. This does not sound like what you are looking for. We do offer RhoConnect Push (as explained in this webinar) but that would require you to implement the RhoConnect solution. We do support native android Google Cloud Messaging out of the box yet, if you want you can enable this and expose it to you application by writing a native extension for it.

            • Re: Push Notifications in RhoElements

              Thanks Rob! It sounds like we might be able to make this work.

              • Re: Push Notifications in RhoElements
                Mark Nongkhlaw

                Robert Galvin wrote:

                The Push API in RhoElements essentially allows you to send http messages to the application (as long as the application is running).

                Hi Rob, can you elaborate a bit? I've not been able to understand the difference between this and the messages being pushed thru Rhoconnect or GCM.



                  • Re: Push Notifications in RhoElements
                    Robert Galvin

                    Here is an example page that is running in a RhoElements Application:


                    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                    <html lang="en">
                              <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
                              <title>Test application - TSD</title>
                              <!-- NPAPI.JS WILL BE INCORPORATED IN ASL.JS -->
                      <script type="text/javascript">
                                        var rotation = 'Left';
                      signal.signalEvent = "signalEvent(%json)";
                                        function signalEvent(json){
                                                  document.getElementById('ip').innerText = 'http://' + json.ipAddress + ':8080/push?message=test%20message&value=my_value';
                                                  document.getElementById('ip').href = 'http://' + json.ipAddress + ':8080/push?message=test%20message&value=my_value';
                                                  document.getElementById('mac').innerText = json.macAddress;
                                        push.detected = 'detected(%s, %s)';
                                        function detected(p1, p2){
                                                  alert(p1 + '|' + p2);
                              <div class="content">
                                        <p>Your mac address: <span id="mac" style="color:blue"></span></p>
                                        <p>Your push address:<a id="ip"></a></p> 
                                        <p>On a successful push you should be able to see an alert box with the push params.</p>

                    This basically tells the web page to listen to port 8080 for any incoming HTTP requests. From another machine (you can do this in your browser to simulate),you could simply try to browse to http://IPAddressofTheDevice:PortValue/push?param1=val1&param2=val2


                    The app would detect it and the 'detected' function would get called because I set push.detected = 'detected(%s,%s)'.


                    So you would need the following in order for this to work:

                    1) The device must be accessible via HTTp from the server/sender of the push message

                    2) The application must be running on the device

                    3) The server/sender needs to know the IP address of the device.

                  • Re: Push Notifications in RhoElements

                    I had a few follow up questions on this (after watching the webinar http://www.youtube.com/watch?feature=player_embedded&v=IeUTjBliLkE#!)


                    This says it works assuming the application is running.  If the application we create that implements RhoMobile Push is running but is not in currently the application in focus or if the screen is off, would be be able to alert the user via an Android notification or vibration/sound when a push message was received?


                    The solution we are trying to provide would be something similar to the way that application notifications work through GCM, but behind the firewall.  Are there any solutions you are aware of that solve this?  For example I can get alerts at the OS level that allow us to wake the device, show notifications or while in the application update the application.  It seemed easier with C2MD.  I am wondering if this push addresses the same use cases or a subset (which are all in the application).