Page 1 of 2

Execute rest service on another page

Posted: Sat Mar 09, 2013 2:30 pm
by Joe Bohen

Hi,

Is it possible to execute a rest service that is located on page 2 of my app from page 1 of my app.

Regards,
Joe


Execute rest service on another page

Posted: Sat Mar 09, 2013 3:18 pm
by maxkatz

The service you want to execute has to be on the page.


Execute rest service on another page

Posted: Sat Mar 09, 2013 6:01 pm
by Joe Bohen

Hi Max, Thanks for the reply, I have managed to implement this! But not for every service I am using a push notification handler to have the app re-query the Tiggzi database and update the data on the app.

var A = data.aps.alert;
if (A.indexOf("SERVICE1") = 0){
toast('Jobs Updated');
restservice1.execute({});
return;
}
else if (A.indexOf("LOCATIONUPDATE") = 0){
getPosition();
return;
}
else if (A.indexOf("Message") = 0){
playBeep();
alert (data.aps.alert);
Tiggzi("messagelabel").text(data.aps.alert);
return;
}

Because I want to alert the user to some events and not to others I have turned off the push alert, sound and badge, this works really nicely but it would be even better if I could add the notification message to the ones I wish to show! Don't suppose this is possible.

Regards,
Joe


Execute rest service on another page

Posted: Sat Mar 09, 2013 7:28 pm
by maxkatz

A service instance has to be present on a page, in order to be invoked. You could invoke it from JavaScript.


Execute rest service on another page

Posted: Sat Mar 09, 2013 8:37 pm
by Joe Bohen

Sorry Max, thought that was what I had asked!


Execute rest service on another page

Posted: Sat Mar 09, 2013 9:12 pm
by Emmz

Joe.. I put all my rest services on page 1 (main page). They are always available that way even on a multi-page template.
I use localstorage to send parameters and respond to results from the service..
My calls to the service are within an array like so..
code
var type=new Array("Service1.execute({});","Task ID","INSERT INTO 'test' SET ","'item1'","'item2'","'item3'");
/code
Store it. retrieve, parse and use eval to execute..
If your not passing data just use..
var myservice = "Service1.execute({});"//yourservice name here
Now to run the service use eval(myservice)
Or direct eval(Service1.execute({}););

Hope this helps


Execute rest service on another page

Posted: Sun Mar 10, 2013 12:51 am
by Joe Bohen

Its really useful to have your input I have followed your posts on tiggzi and have found them very valuable thanks.


Execute rest service on another page

Posted: Sun Mar 10, 2013 2:52 pm
by Emmz

Just hate to see folks struggle with the same stuff i did months ago..
Your welcome. And Thank you...


Execute rest service on another page

Posted: Sun Mar 10, 2013 2:53 pm
by Emmz

ps. I'll send off php code within the hour.


Execute rest service on another page

Posted: Mon Mar 11, 2013 9:28 am
by Joe Bohen

Hi Neil,

Thanks for the PHP, I have most of the processes you have In PHP in .net the one element I’m missing is how you are able to grab the GCM Key for the device. Do you do this with javascript compiled in Tiggzi or do you export your project into eclipse and build the method there. Any example you have on how you are doing this or advise you can give is much appreciated.

Regards,
Joe