Reputation: 439
I am creating an application that requires a constant long polling of AWS Simple Queueing Service. When a message is received I need to trigger certain actions depending on the active controller.
From my research the notification pattern seems like it should work well (though I'm open to suggestions). I can use GCD to get the thread in background. I have 2 main questions
Where should I put this code (It can't be in the controllers, and AppDelegate doesn't seem appropriate)?
How should I handle application events (like being backgrounded, etc) and allow them to act on this thread (to pause or resume the polling)?
Upvotes: 0
Views: 82
Reputation: 342
Why not create a singleton ApiController that has GCD and does all the api calls and notifies your view controllers, this singleton class can be called from any view controller and once you enable run in the background, it should have to permission to run in the background.
Upvotes: 1