Cant figure this one out. Everything works fine when the app is active, and than sometimes when i move the app to the background(pressing the home button) a
I think that there are different things that could cause the problem:
-beginConfiguration and -commitConfiguration block of code. Each time you setup something in the session it will takes time to do it. Wrapping your configuration code between those method will guarantee that all the changes are committed in one shot, reducing the overall session creation timeUIApplicationDidEnterBackground and UIApplicationWillEnterForeground to pause and start again the session.-viewWillAppear each time this method is called you create a session but, is not really clear from your code if you get rid of it. You should separate and balance the session creation and destroy. Provide a -setupSession and a -tearDownSession methods. Make sure that the setup is called only if there is no active session and make sure that when you don't need the session anymore you get rid of it by calling the teardownSession. In SWIFT you na use a @lazy variable and destroy the session in deinit() or -viewWillDisappear.I undestand that is huge refactor, but I'm this way I'm pretty sure that you will experience less problems in the future.