Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
536 views
in Technique[技术] by (71.8m points)

ios - requestRecordPermission does nothing

Since the update of iOS 7 there has been some changes with recording applications. I have an app that used to work with iOS 5 and 6, but when I tried to run it on iOS 7 - recording didn't respond.

I checked the internet and saw there's a new method that needs to be called. I tried to place this code in viewDidAppear:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    if([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission:)])
    {
        [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
            NSLog(@"permission : %d", granted);
        }];
    }
}

'granted' is always 1 although I didn't grant any permission nor saw any request popup.

Btw I'm trying to handle this using xcode 4.6.3. I made a category for AVAudioSession with requestRecordPermission method, since this method is available in iOS 7 only.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I ran into the same problem while testing on iOS7 simulator, it looks like requestRecordPermission does not work in simulator and "granted" is always returned YES. You have to test it on a real device.

If you have tested it once on a device and responded to the permission popup then permission popup will not come again until a reset of location & privacy is done.

To reset Location & Privacy follow these steps

Go to Settings -> General -> Reset -> Reset Location & Privacy and then press "Reset Warnings" when asked.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...