2

I am new IOS developer using swift. I have created a Radio App (streams Live). I want to make it to run in the background when user minimize the app or do some other stuff. Right now, it stops streaming audio as soon as sent to background and continuous again as soon as it is brought to foreground.

I searched few articles and other forums, but couldn't find any help. I am really new to IOS development and don't know about controls/functions in the AppDelegate.swift.

So far I enabled the option under Project Capabilities Tab as following also made change in info.plist file, however Application still stops as soon as enters in the background.

background modes enabled

Any word of advice will be greatly appreciated. Thanks for your time and views.

nhgrif
  • 61,578
  • 25
  • 134
  • 173
heavyguidence
  • 363
  • 1
  • 8
  • 23
  • i am also new, but just an idea...look into your AppDelegate file. Section `func applicationDidEnterBackground(application: UIApplication) {}` – Chameleon May 24 '15 at 17:15
  • 1
    possible duplicate of [How to Play Audio in Background Swift?](http://stackoverflow.com/questions/30280519/how-to-play-audio-in-background-swift) – Leo Dabus May 24 '15 at 17:17
  • I am not aware of much about DidEnterBackground section and have hard time to understand the documentation at this point. @Leonardo looks like that is something different. Where do i have to paste that `var categoryError: NSError? if AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: &categoryError) {` code ? – heavyguidence May 24 '15 at 21:44
  • It can be at viewDidLoad – Leo Dabus May 24 '15 at 22:06

1 Answers1

4

I have adding the bool to info.plist file saying "Application does not run in the background = "NO"

Now I can run app in the background. I hope this solve the problem for others as well.

heavyguidence
  • 363
  • 1
  • 8
  • 23