Private API show red pulsating double-height status bar (often used for recording)

474 views Asked by At

I am looking for a private API example on how to show the red pulsating double-height status bar that is used when recording audio. I would like to enable this status bar from my app without starting recording. I want just the status bar and I want it to be system-wide so if I put my app in background I want to see it still. To start recording would actually be a good workaround, the problem is that I need to trigger the status bar from the app while it is running in the background (for example after a silent push)

I remember being able to modify the global status bar in early iOS but I have lost the code and I hope someone know if this can be done in iOS 8 and can share some hints on which API I should use. I know that Apple have locked a lot of functionality behind entitlements now days, I hope though that this is something they haven't locked up.

Please note that this is not for app store submission but rather an internal app and I am not looking for pros and cons about doing this but rather technical info on how to do it.

EDIT:

Just for completeness, I have tried to start recording in the background and this does not seem to work. The code works perfectly when the app is in foreground but when the app is in background it just [self.recorder record] returns false. Being able to start the recorder from background would be perfect, that would also solve my problem. When I try to start recording in background I get "ERROR! Failed to start recorder" (see below)

[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
    if (!granted) {
        NSLog(@"Permission not granted");
    }
}];

NSError *error;

NSArray *pathComponents = [NSArray arrayWithObjects:
                           [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
                           @"Audio.m4a",
                           nil];
NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];

AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryRecord error:&error];

NSDictionary *recordSetting = @{
                                AVFormatIDKey:[NSNumber numberWithInt: kAudioFormatMPEG4AAC],
                                AVSampleRateKey:[NSNumber numberWithFloat:16000.0],
                                AVNumberOfChannelsKey:[NSNumber numberWithInt: 1]
                                };


// Initiate and prepare the recorder
self.recorder = [[AVAudioRecorder alloc] initWithURL:outputFileURL settings:recordSetting error:&error];
self.recorder.delegate = self;
BOOL prepared = [self.recorder prepareToRecord];
if (!prepared) {
    NSLog(@"ERROR! Failed to prepare recorder");
}

[[AVAudioSession sharedInstance] setActive:YES error:&error];
BOOL isRecording = [self.recorder record];
if (!isRecording) {
    NSLog(@"ERROR! Failed to start recorder");
}
0

There are 0 answers