[Aerogear-users] Testing push in Cordova

Anton Hughes kurrent93 at gmail.com
Fri Jan 22 18:51:13 EST 2016


Ok so I managed to deploy my cordova app onto genymotion. Actually that
wasnt too difficult.
But, alas, it still does not connect to the UPS.

I have updated the pushServerURL value to use my hosts ip.

My index.html looks like this - I notice it is referencing cordova.js, but
this file is missing in the eclipse project. I assume eclipse automagically
adds it when the project is built.
Ive removed the send, variant and variant secret - to protect the identity
of the innocent.

<!DOCTYPE HTML>
<html>
<head>
  <title>Demo</title>
</head>
<body>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8"
src="jquery_1.5.2.min.js"></script>

<script type="text/javascript">

var app = {
 // Application Constructor
 initialize: function() {
   this.bindEvents();
 },
 // Bind Event Listeners
 //
 // Bind any events that are required on startup. Common events are:
 // 'load', 'deviceready', 'offline', and 'online'.
 bindEvents: function() {
   document.addEventListener('deviceready', this.onDeviceReady, false);
 },
 // deviceready Event Handler
 //
 // The scope of 'this' is the event. In order to call the 'receivedEvent'
 // function, we must explicitly call 'app.receivedEvent(...);'
 onDeviceReady: function() {
   app.receivedEvent('deviceready');
   var pushConfig = {
     pushServerURL: "http://192.168.1.40:8080/ag-push/",
     android: {
       senderID: "",
       variantID: "",
       variantSecret: ""
     }
   };
push.register(app.onNotification, successHandler, errorHandler, pushConfig);

function successHandler() {
 console.log('success')
}

function errorHandler(message) {
 console.log('error ' + message);
}
},
onNotification: function(event) {
 alert(event.alert);
},
// Update DOM on a Received Event
receivedEvent: function(id) {
 var parentElement = document.getElementById(id);
 var listeningElement = parentElement.querySelector('.listening');
 var receivedElement = parentElement.querySelector('.received');

 listeningElement.setAttribute('style', 'display:none;');
 receivedElement.setAttribute('style', 'display:block;');

 console.log('Received Event: ' + id);
}
};

app.initialize();

  document.addEventListener('deviceready', onDeviceReady, true);

</script>
<div id="home">
  <div id="app-status-div">
    <ul id="app-status-ul">
      <li>AeroGear PushPlugin Unified Push Demo</li>
    </ul>
  </div>
</div>
</body>
</html>

Can anyone see anything obviously wrong?

How does one debug in such a situation?

Thanks


On Sat, Jan 23, 2016 at 12:21 AM, Anton Hughes <kurrent93 at gmail.com> wrote:

> Ok, I have managed to get setup with Genymotion, and have the google tools
> installed.
>
> How, then, can I deploy the cordova project to the genymotion vm? Is there
> a way to do that from within Eclipse?
>
> Thanks
>
> On Fri, Jan 22, 2016 at 2:35 PM, Anton Hughes <kurrent93 at gmail.com> wrote:
>
>> Thanks Luke. I will try this.
>>
>> On Fri, Jan 22, 2016 at 2:31 PM, Luke Holmquist <lholmqui at redhat.com>
>> wrote:
>>
>>>
>>>
>>> On Fri, Jan 22, 2016 at 8:28 AM, Anton Hughes <kurrent93 at gmail.com>
>>> wrote:
>>>
>>>>
>>>> On Fri, Jan 22, 2016 at 2:25 PM, Luke Holmquist <lholmqui at redhat.com>
>>>> wrote:
>>>>
>>>>> just a thought that popped into my head.   The url pointing to your
>>>>> UPS server shouldn't be localhost, since there is no localhost on the
>>>>> device.  not sure if thats how you have it configured, though. but this
>>>>> always bites me
>>>>
>>>>
>>>> The wise expression of Homer Simpson comes rushing into mind!
>>>> I'm away from my dev environment, so cannot test - but, yes I am using
>>>> localhost in the cordova project.
>>>>
>>>> So if not localhost, then what?
>>>>
>>> if you are running the UPS server on your local machine, then it would
>>> be your IP instead of localhost.  The device just needs to "see" it, so
>>> that means you need to be on the same network.   unless you are running it
>>> in the cloud or something
>>>
>>>>
>>>> _______________________________________________
>>>> Aerogear-users mailing list
>>>> Aerogear-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/aerogear-users
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Aerogear-users mailing list
>>> Aerogear-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/aerogear-users
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-users/attachments/20160123/f76a570a/attachment.html 


More information about the Aerogear-users mailing list