iOS app does not play audio from bluetooth headset

Builded Unity app for iOS and Android. In iOS app audio won’t be played in bluetooth headset. In android does. Headset itself works perfectly. Same problem with different bluetooth headsets.

Couldn’t find any solution. Have anyone had this problem? Any glue why?

Unity 2018.1.5f1
iOS 10 and 11

Managed to FIX this problem.


Open the generated project in Xcode. Find and open UnityAppController.mmfile.
And add these lines to UnityAppController.mm:


At the beginning of the file add:

#import <AVFoundation/AVFoundation.h>

Then find this function in mentioned file:
- (void)startUnity:(UIApplication*)application:

If you don’t need to record add in the end of this function these 2 lines:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];

If you need to record add in the end of this function these 2 lines:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord 
        withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];