I have developed a music app. While testing it, i got a skype call which is stopping audio playing in my app in background. How can i handle this? I am not understanding this behaviour. I am using ipad with iOS 8.1. Is this a behaviour of skype itself?
1 Answers
This is becuase Skype is VoIP app and iOS default behaviour is when receiving incoming call, running apps are temporarily become inactive.
I'm not sure what you mean by 'how I can handle this'.
If you are asking whether you can stop it from happening, you can't, since this is the default iOS behaviour.
However, if you just need to stop/start certain functions of your app (such as restarting your music player, if it didn't happened automatically), You can do this by using the app delegate methods applicationWillResignActive
, which is called when an application is about to become inactive, as happened to you, when you've received a skype phone call, and applicationDidBecomeActive
which is called when an application become active again.
Key points from apple documentation above the above two:
applicationWillResignActive:
This method is called to let your app know that it is about to move from the active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the app and it begins the transition to the background state. An app in the inactive state continues to run but does not dispatch incoming events to responders.
You should use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. An app in the inactive state should do minimal work while it waits to transition to either the active or background state.
applicationDidBecome:
This method is called to let your app know that it moved from the inactive to active state. This can occur because your app was launched by the user or the system. Apps can also return to the active state if the user chooses to ignore an interruption (such as an incoming phone call or SMS message) that sent the app temporarily to the inactive state.
You should use this method to restart any tasks that were paused (or not yet started) while the app was inactive. For example, you could use it to restart timers or throttle up OpenGL ES frame rates. If your app was previously in the background, you could also use it to refresh your app’s user interface.
Full documentation can be found here: UIApplicationDelegate Protocol