Hi,

On macOS we selectively link in the relevant permission plugins based on what 
you’ve declared in your Info.plist.
This magic depend on using the qt_ prefixed function for adding your executable:

https://doc.qt.io/qt-6/qt-add-executable.html

Cheers,
Tor Arne

On 8 May 2024, at 16:44, Sley HORTES <sleyhorte...@gmail.com> wrote:

Hello All, Hope You are doing fine.

I am all new to Qt and this email is  concerning an issue that I have had 
lately regarding a chat application which requests access to use the Microphone.

I have read the Documentation on how to handle it. I have written exactly what 
they said but I didn’t receive the popup message which request access to the 
microphone. The function where I tried to do so is below, the Info.plist file 
command along with the terminal message that is prompted when trying to use it.

Function:

void client_chat_window::start_recording()
{
QMicrophonePermission microphonePermission;

switch (qApp->checkPermission(microphonePermission))
{
case Qt::PermissionStatus::Undetermined:
qApp->requestPermission(microphonePermission, this, [=]()
{ qDebug() << "Undetermined: Microphone permission granted!"; });

std::cout << std::endl;
break;

case Qt::PermissionStatus::Denied:
qApp->requestPermission(microphonePermission, this, [=]()
{ qDebug() << "Asking permission within the Denied case"; });

qWarning("Denied: Microphone permission is not granted!");
std::cout << std::endl;
break;

case Qt::PermissionStatus::Granted:
QMediaCaptureSession session;

QAudioInput audioInput;
session.setAudioInput(&audioInput);

QMediaRecorder recorder;
session.setRecorder(&recorder);

recorder.setQuality(QMediaRecorder::HighQuality);
recorder.setOutputLocation(QUrl::fromLocalFile("test.mp3"));
recorder.record();
qDebug() << "Recording started!";

std::cout << std::endl;
break;
}
}


Within the Info.plist, I've written this:
<key>NSMicrophoneUsageDescription</key>
<string>We need access to your microphone to record audio for voice 
chat.</string>


CMakeLists.txt file related to the app:
add_executable(client
client_main.cpp
client_main_window.cpp
client_manager.cpp
client_chat_window.cpp
chat_protocol.cpp
chat_line.cpp
)
target_link_libraries(client PRIVATE database_library)

qt_add_resources(client "images"
PREFIX "/images"
FILES send_icon.png
)

set(MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)

set_target_properties(client PROPERTIES MACOSX_BUNDLE ON)



Terminal Message:
qt.permissions: Could not find permission plugin for QMicrophonePermission. 
Please make sure you have included the required usage description in your 
Info.plist

I really Hope That You will spot where I went wrong and give me an hint on how 
to solve it.
Thanks.




On May 5, 2024, at 5:59 AM, interest-requ...@qt-project.org wrote:

Welcome to the Interest@qt-project.org mailing list!

To post to this list, send your message to:

 interest@qt-project.org

General information about the mailing list is at:

 https://lists.qt-project.org/listinfo/interest

If you ever want to unsubscribe or change your options (eg, switch to
or from digest mode, change your password, etc.), visit your
subscription page at:

 https://lists.qt-project.org/options/interest/sleyhortes13%40gmail.com


You can also make such adjustments via email by sending a message to:

 interest-requ...@qt-project.org

with the word `help' in the subject or body (don't include the
quotes), and you will get back a message with instructions.

You must know your password to change your options (including changing
the password, itself) or to unsubscribe without confirmation.  It is:

 c5x3KgHZbCTv3HJ

Normally, Mailman will remind you of your qt-project.org mailing list
passwords once every month, although you can disable this if you
prefer.  This reminder will also include instructions on how to
unsubscribe or change your account options.  There is also a button on
your options page that will email your current password to you.

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to