Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Had the same problem, but found a solution for this..</p> <p>Look here: <a href="https://devforums.apple.com/message/395049#395049" rel="noreferrer">https://devforums.apple.com/message/395049#395049</a></p> <p><strong>The content of the above link:</strong></p> <hr> <p>Replace <code>APPNAME</code> with your own app name!</p> <p>Im on iOS 4.2.1</p> <p><strong>EDIT: Working with iOS5 + 6 + 7 beta so far</strong></p> <p>Add <code>UIBackgroundModes</code> in the <code>APPNAME-Info.plist</code>, with the selection App plays audio</p> <p>Then add the <code>AudioToolBox</code> framework to the folder frameworks.</p> <p>In the <code>APPNAMEAppDelegate.h</code> add:</p> <pre><code>#import &lt;AVFoundation/AVFoundation.h&gt; #import &lt;AudioToolbox/AudioToolbox.h&gt; </code></pre> <p>so it look like this:</p> <pre><code>... #import &lt;UIKit/UIKit.h&gt; #import &lt;AVFoundation/AVFoundation.h&gt; #import &lt;AudioToolbox/AudioToolbox.h&gt; ... </code></pre> <p>In the <code>APPNAMEAppDelegate.m</code> add the following:</p> <pre><code>// Set AudioSession NSError *sessionError = nil; [[AVAudioSession sharedInstance] setDelegate:self]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:&amp;sessionError]; /* Pick any one of them */ // 1. Overriding the output audio route //UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; //AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &amp;audioRouteOverride); // 2. Changing the default output audio route UInt32 doChangeDefaultRoute = 1; AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &amp;doChangeDefaultRoute); </code></pre> <p>into the</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { </code></pre> <p>but before the two lines:</p> <pre><code>[self.window addSubview:viewController.view]; [self.window makeKeyAndVisible]; </code></pre> <p>Build your project and see if theres any error, If not, try debug on Device insted of the Simulator, it CAN bug on simulator.</p> <p>Hope this helps others with same problem..</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload