我如何向用户请求mic记录许可 [英] How do i request mic record permission from user

查看:140
本文介绍了我如何向用户请求mic记录许可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新的iOS7开发人员SDK,现在应用程序请求用户在第一次尝试录制时允许他从麦克风录制。

I am using the new iOS7 developer SDK and now the app request from the user his permission to record from mic when the App try to record in the first time.

我的应用程序将在倒计时后进行记录,因此用户无法看到此请求。
我使用此代码检查 requestRecordPermission

My App will record after a countdown,so the user can't see this request. I use this code to check the requestRecordPermission:

[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) {
            if (granted) {
                // Microphone enabled code
            }
            else {
                // Microphone disabled code
            }
        }];

但是在开始录制之前我怎么能自己触发请求?

But how can i trigger the request by myself before i start to record ?

推荐答案

在新的iOS7中,这很简单,试试这个:

In the new iOS7 it's very simple try this:

if([[AVAudioSession sharedInstance] respondsToSelector:@selector(requestRecordPermission)])
{
    [[AVAudioSession sharedInstance] requestRecordPermission];
}

这篇关于我如何向用户请求mic记录许可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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