Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Execute rest service on another page

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Execute rest service on another page

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

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Execute rest service on another page

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Execute rest service on another page

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

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Execute rest service on another page

Sorry Max, thought that was what I had asked!

Emmz
Posts: 0
Joined: Sat Jun 23, 2012 11:06 pm

Execute rest service on another page

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

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Execute rest service on another page

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

Emmz
Posts: 0
Joined: Sat Jun 23, 2012 11:06 pm

Execute rest service on another page

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

Emmz
Posts: 0
Joined: Sat Jun 23, 2012 11:06 pm

Execute rest service on another page

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

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Execute rest service on another page

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

Return to “Issues”