Case of study GPS + INTERNET CONNECTION + BACKGROUND SERVICE

Hello community!

I have been studying the ionic from 2 weeks and I love it .
I would like to ask people with more experience than me if is possible to develop a challenge that I have in mind.

The challenge that i want to develop is simple and easily achievable on native android app.
So, what I want to achieve is the possibility to run a code every X seconds in background:
loop
{
var time = new Date();
var gps = Get_gps_pos(); //not hard too
var hasConnection = HasInternetConnection(); {true,false}

writeToTxt(time,gps,hasConnection);
}

Result in txt or localstorage:
2016-01-01 10:00#41,222#-7,333#false
2016-01-01 10:30#41,222#-7,333#true

2016-01-01 11:00#41,222#-7,333#true

What do you guys think? Is this possible with ionic?

Best Regards,
Vitor Pereira