requestRecordPermission 什么都不做 [英] requestRecordPermission does nothing

查看:30
本文介绍了requestRecordPermission 什么都不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自 iOS 7 更新以来,录音应用程序发生了一些变化.我有一个曾经在 iOS 5 和 6 上运行的应用,但是当我尝试在 iOS 7 上运行它时 - 录制没有响应.

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.

我上网查了一下,发现有一个新方法需要调用.我试图将此代码放在 viewDidAppear 中:

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' 始终为 1,尽管我没有授予任何许可,也没有看到任何请求弹出窗口.

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

顺便说一句,我正在尝试使用 xcode 4.6.3 来处理这个问题.我使用 requestRecordPermission 方法为 AVAudioSession 创建了一个类别,因为该方法仅在 iOS 7 中可用.

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.

谢谢.

推荐答案

我在 iOS7 模拟器上测试时遇到了同样的问题,看起来 requestRecordPermission 在模拟器中不起作用,并且granted"总是返回 YES.您必须在真实设备上对其进行测试.

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.

这篇关于requestRecordPermission 什么都不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆