A Noobish Question re Ionic Native and Callback Fns

Assuming we have a plugin such as the BackgroundGeolocation installed and configured on our application, one scenario would be to issue an HTTP request to a server with some type of Auth Token to identify the requester and log their position.

Since this is a background task, which runs even if the application may not be running, I am confused as to what is the allowed scope within the callback functions. What will this refer to when the callback is fired? Can I use the Storage service or one of my own services to pull my cached user token?

I am aware that this specific plugin provides an HTTP parameter with Header options, but I am just using it as a case to give the question some concreteness.


If you write arrow functions, this is bind lexically. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Lexical_this

Yes, you can make your own services and inject it into your component. https://angular.io/docs/ts/latest/guide/dependency-injection.html