On Mon, Feb 24, 2014 at 11:41 AM, Miguel Lemos <miguel21op@gmail.com> wrote:
Matthias.

I didn't post in issues, because it's a more generic post. If you think it's better to move it, please tell.

No this list (aerogear-dev) is still the right place. But my suggestion was to send new email (threads) per topic.

Originally this email (thread) was started because you had issues getting started. We solved that.

Now you had four different questions for a running app.  If a different user has a question around geofencing as well, I'd perhaps not be searching inside of an email thread around "Issues with Aerogear on Cordova" :)

Note: the issues list is just for our JIRA instance. It posts updates for all our JIRA instances to their. Not intended for sending emails to it. It's really just for JIRA.

-Matthias


 

M

Enviado do meu iPhone

No dia 24/02/2014, às 09:49, Matthias Wessendorf <matzew@apache.org> escreveu:

Hi Miguel,

I'd suggest we start using a new thread - perhaps a new thread per topic? Would be good to keep communication focused around a certain topic;
Otherwise this thread gets longer and longer and longer, and is hard to search for certain words.

I interepret this thread as being solved, as you have your app working. These questions here are more details or advanced bits around a working push integration.

Thanks!
Matthias


On Mon, Feb 24, 2014 at 10:19 AM, Miguel Lemos <miguel21op@gmail.com> wrote:
Hi all!

After further work around Aerogear for Cordova, I have this questions:

a) If the app is running in the foreground, I can control what the notification shows (or not), because I can use the parameters sent in the message to decide if I show it or not, or  what I'm going to do according to it. Example:

function onNotification(e) {

      tit =  e.payload.at;
      notif= e.payload.av;
      ent =  e.payload.en;
      url=   e.payload.ul;

    if (e.foreground) {
          if (ent==entID){ // a given condition
            navigator.notification.confirm(
            notif,
            onConfirmDo,
            tit,
            'OK' 
        );
            function onConfirmDo(button){
                    if(button == "1" && url){
                     openInside(url+'&imei='+imei);
                    }
             }
           
          }
      }
    else {  
            if (e.coldstart) {
                //
            }
            else {
                //
            }
    }
}


Of course in many cases this is not a very effective solution, because I should filter the message before she leaves the server. For instance: I want to show a notification to all my customers under 40 y.o. According to this:

http://aerogear.org/docs/specs/aerogear-server-push/

...I can use "alias", "categories", etc., to perform such segmentation; but I don't know how to send that information to your server.

b) Geofenced notifications

This is a very important matter, as you may know. I can use a trick to do that: I send a push notification without the "alert" token and I store it locally (I found out that without the "alert" parameter the notification will not show in the notification tray if the app is running in background). Later on, I trigger the alert if the location criteria is matched (of course, I must send geo-coordinates and a radius as message parameters). Is there a more effective / logical way to do that?

c) Is there some way yo have control over the alert on the notification tray? That is: make it show only if a given criteria is matched?

d) Please see the piece of code above: the coldstart event seems not to work, whatever I put on it. It always triggers the foreground event. That is: if the user touches the notification tray alert, next it always opens the foreground routine.What am i doing wrong?


Thank you again

M


On Fri, Feb 21, 2014 at 4:59 PM, Matthias Wessendorf <matzew@apache.org> wrote:



On Fri, Feb 21, 2014 at 5:57 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Ah!
Ich habe deutsch in schule gelernt aber ich habe fast alles vergessen. Schade :-(

Klingt gut :) 


 


On Fri, Feb 21, 2014 at 4:53 PM, Matthias Wessendorf <matzew@apache.org> wrote:
all remote workers; I am from Germany


On Fri, Feb 21, 2014 at 5:47 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
The same to you guys;-)

PS - Where's  you people main base (if there's one)? Switzerland?


On Fri, Feb 21, 2014 at 4:40 PM, Matthias Wessendorf <matzew@apache.org> wrote:
Awesome!

I am glad it works :-) 

Have a nice weekend!

-Matthias


On Fri, Feb 21, 2014 at 5:31 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Matthias,

Yes, it was it! I stripped from that, and I reduced the thing to the basics  and it works now :-)

So, my friend, If you want somebody to use a PHP working code, there it goes the full code (of course without the bells and whistles...).
Some parts of the curl are optional. Use as you wish.

A special thanks to you and Sebastian. Your help was really priceless;-)


<?php
header('Content-type: text/html; charset=utf-8');
ini_set('display_errors', true);

$key="your key";
$secret="your secret";

$ch = curl_init('https://aerogear-metalpush.rhcloud.com/rest/sender'); // your URL


$data = array(
    'message' => array(
        'alert'    => 'Anything',   //  don't forget 107 char limit for  iOS, for  a total payload of 256 for the whole data sent !!!
        'badge'    =>   // a numeric value

    )
);

$data_st = json_encode($data);
$headers = array("Accept: application/json", "Content-Type: application/json");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 6);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_VERBOSE, true);

curl_setopt($ch, CURLOPT_USERPWD, "$key:$secret");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);                                                                
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_st); 

$result = curl_exec($ch);

if (empty($result)) {
      echo 'Erro do curl: '.curl_error($ch),curl_errno($ch);
     }
     curl_close($ch);
     echo $result;
     return $result;

/*
The same at the console:
$ curl -3 -u "key:secret" -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"message": {"alert":"anything", "badge":1}}' https://aerogear-metalpush.rhcloud.com/rest/sender

*/

?>


On Fri, Feb 21, 2014 at 4:08 PM, Matthias Wessendorf <matzew@apache.org> wrote:


On Fri, Feb 21, 2014 at 5:02 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Yes I can, the problem is that the whole thing is stringified later before the POST.

You are saying some sort of library is changing the 1 to "1" ?

If so, that library is broken.



Regarding stringifing: in curl we do:

curl ...... -d '{ some_json_object}' ......

which also posts the _entire_ object as a string


 
Let me do some more testing. 


I'm a stubborn guy, did ya know? ;-)


On Fri, Feb 21, 2014 at 3:56 PM, Matthias Wessendorf <matzew@apache.org> wrote:



On Fri, Feb 21, 2014 at 4:53 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Maybe I must strip the code of the json encode part, because I do that before the PUT and this "kills" anything that isn't text :-(


I think I don't get why you can not be using this:

$data = array(
    'message' => array(
        'atl'    => 'Aviso', 
        'avs'    => 'Mensagem', 
        'badge'    => 1
    )
)


where the 1 is a number, not a string




-Matthias
 


On Fri, Feb 21, 2014 at 3:47 PM, Matthias Wessendorf <matzew@apache.org> wrote:



On Fri, Feb 21, 2014 at 4:45 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Yes, of course it's different! That's why I said that it can not be sent in the middle of a Json array! But I just don't now how I can do it, right now :-(


$data = array(
    'message' => array(
        'atl'    => 'Aviso', 
        'avs'    => 'Mensagem', 
        'badge'    => 1
    )
);


using the http://phpepl.cloudcontrolled.com/ shows me this result:

{"message":{"atl":"Aviso","avs":"Mensagem","badge":1}}


 



On Fri, Feb 21, 2014 at 3:35 PM, Matthias Wessendorf <matzew@apache.org> wrote:



On Fri, Feb 21, 2014 at 9:54 AM, Miguel Lemos <miguel21op@gmail.com> wrote:
Hi!

I'm trying to create a php batch to test faster my notifications. So I did this (simplified example):

$ch = curl_init('https://aerogear-metalpush.rhcloud.com/rest/sender');

$data = array(
    'message' => array(
        'atl'    => 'Aviso',
        'avs'    => 'Mensagem',
        'badge'    => '1'



Can you log the JSON somewhere, on a console ? 

I am not sure for PHP..., but I am w/ Sebi that "1" is something different than 1

That said, putting "badge":"1" (string value) in, via curl does cause an error on the server.

Due to the async nature of notifcation delivery, we receive the message, return HTTP 200, and process it.

The "1" value does NOT work.

-Matthias


 
    )
);

$data_st = json_encode($data);
$headers = array("Accept: application/json", "Content-Type: application/json");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 6);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$key:$secret");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);                                                                
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_st); 

$result = curl_exec($ch);

I think that's something wrong with the $data array because the server returns: " The request sent by the client was syntactically incorrect ().

If I strip the string from the "message"  it returns "job submitted", but of course I don't receive nothing.

Thanks again

M




On Thu, Feb 20, 2014 at 8:48 AM, Sebastien Blanc <scm.blanc@gmail.com> wrote:
This is really cool Miguel !
Don't hesitate to ask us other questions and also , like you did with your screenshot, give us feedback !
Thanks again for your interest in the project.
Sebi
 


On Thu, Feb 20, 2014 at 9:43 AM, Miiguel Lemos <miguel21op@gmail.com> wrote:
Not all, but a couple of steps on the right direction, I hope ;-)

Enviado do meu iPad

No dia 19/02/2014, às 21:20, Matthias Wessendorf <matzew@apache.org> escreveu:

Nice!

Glad you are all set!

-Matthias


On Wed, Feb 19, 2014 at 4:38 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
A small souvenir ;-)

Thanks again




On Wed, Feb 19, 2014 at 3:20 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Hi Matthias,

Maybe I didn't make myself clear, but your answer was clear enough to respond to my post :-)

Thanks again.

Carry on!

M



On Wed, Feb 19, 2014 at 3:05 PM, Matthias Wessendorf <matzew@apache.org> wrote:



On Wed, Feb 19, 2014 at 3:43 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Dear Matthias,

According to the information posted in the url below, I can send (and read) several parameters / keys in the scope of the notification service (as it should be...):

http://aerogear.org/docs/specs/aerogear-push-messages/

According to the values on it, the receiver should have the capacity to decide what to do next.

First, and the easiest thing: don't show  the "Alert" text, but any other part of  content received and / or change "Alert" to  another language, for instance.

Not sure I follow.

The 'alert' is a keyword on iOS, which our server (and our Cordova Libs) do recognize. What do you want to change there ? 
For the completion of our spec, we are showing all of the keywords, that are supported.

 

Second, if I create (for instance) a lat, lon and rad parameters, I can decide if I show the notification immediately, or only when the user reaches a matchable location, within a given radius. 
This is just an example of the freedom that must be available to decide what to do according to a given parameter that the software on the client's side can interpret. The message itself may not be the most important part of the whole thing...

If you don't want or need that alert, simply leave it our of the payload. It's just part of the demo/docs as that is quite handy to get going.
 

So, the question is: how can I read those parameters / keys before deciding to do with the notification? Through a "regular" object keys iterator? Thank you very much again. If there's some place in the documentation where I can understand that, please let me know.

yes, like here (using alert just as an example):


 function onNotification(e) {
     alert(e.payload.foo);
     alert(e.payload.key);
  }

And the curl for that would be something _like_ this:
curl -3 -u "ID:secrect" -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"message": {"foo":"bar value", "key":"HELLO"}}' https://something-doamin.rhcloud.com/rest/sender


-Matthias


 


Miguel



On Wed, Feb 19, 2014 at 1:34 PM, Matthias Wessendorf <matzew@apache.org> wrote:
Awesome,

we are interested in hearing your feedback.

Good luck w/ the development process!

-Matthias


On Wed, Feb 19, 2014 at 2:29 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Thanks. Of course I'll give you my feedback ;-)

I've some questions about the service as a whole, but I'll make some more testing and then I'll let you know.

Thank you very much again for your attention.

All the best,

Miguel


On Wed, Feb 19, 2014 at 1:25 PM, Matthias Wessendorf <matzew@apache.org> wrote:



On Wed, Feb 19, 2014 at 2:18 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Hi Matthias,

One of the biggest reasons I'm testing this solutions is because iOS!

Once we already developed a full native Android push (considering geofencing)  notification service. The issue is to port our solution to iOS (not only the notifications, but everything). That's why I'm personally testing Cordova on Android and already partially on IOS. So far so good..

Sounds very interesting. If you are interested, let us know how it goes. 
 

I'm starting with Android because it's easier to me. But next week I want to test your solution  with iOS. Why? Is there any problem?

No problem there at all :-) I was just curious if you target Android first/only.

Greetings,
Matthias
 

Thanks

Miguel



On Wed, Feb 19, 2014 at 1:04 PM, Matthias Wessendorf <matzew@apache.org> wrote:



On Wed, Feb 19, 2014 at 1:20 PM, Miguel Lemos <miguel21op@gmail.com> wrote:
Hi all,

I tested and now it works, thanks.

glad it all worked out 
 

When I tried for  the first time, I tried with the function global, reflecting the Github example. But as it didn't work (because of the "damn" URL issue...) I tried several things, one of them being put the alert function inside the deviceready event. Of course, when I solved the URL thing I never more remembered to put it outside again...

Things like that might happen.

Regarding the URL, we will try to update the OpenShift blog post.

I just checkout project documentation, and it looks like they are already 'right'.



Wondering: Are you building Cordova clients for Android only, or do you plan to use the iOS platform as well ?

Greetings,
Matthias
 


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev



_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev


_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev

_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf