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

查看:639
本文介绍了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);
        }];
    }
}

'授权'总是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在模拟器中不起作用,grant总是返回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天全站免登陆