You can't do long polling from a Trigger app while it's in the background.
When Trigger apps go into the background, JS execution is paused. Listeners for the appPaused event get called when the app goes into the background, with some constraints:
What can be executed in the callback varies by platform:
- Android: Any javascript can be run, but timers may not be fired until the app is resumed, this prevents unnecessary battery usage by the app.
- iOS: A short amount of time is given for execution, it is generally best to assume that callbacks and timers may not fire until the app is resumed.
This isn't something inherent to Trigger, but mobile apps in general, in particular iOS is pretty strict about how long you can run something in the background. This sort of problem is usually tackled using push notifications, which are more reliable (keep working even if your app is killed) and more battery friendly.