QT6 request permittion (notifications in my case)?
-
Hello,
so I have an Android/iOS app with firebase so its able to receive Push Notifications.
Works very fine!however, when app is installed,l it does not receive those notifications... After figuring out I had to go manualy to Android Settings > App > and manualy allow notifications.
In my AndroidManifest.xml I have:
<manifest ...> ... <!-- Devices running Android 13 (API level 33) must allow push notifications --> <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
I thought by the manifest I already set the permittion while app is installed, so its automaticaly allowed, but I guess i was wrong on this...
So what am I missing something?
How do I check if the app have the notification permittion allowed, and if not how to bring up the dialog to allow/deny?- best in QML, if not possible then c++
-
OK, so for Android its kinda simple, just put to main.cpp:
#include <QtCore/qjniobject.h> #include <QtCore/qcoreapplication.h> #include <QtCore/private/qandroidextras_p.h> int main(int argc, char *argv[]) { ... #ifdef __ANDROID__ if (QNativeInterface::QAndroidApplication::sdkVersion() >= __ANDROID_API_T__) { const auto notificationPermission = "android.permission.POST_NOTIFICATIONS"; auto requestResult = QtAndroidPrivate::requestPermission(notificationPermission); //if (requestResult.result() != QtAndroidPrivate::Authorized) { qWarning() << "Failed to acquire permission to post notifications (required for Android 13+)"; } } #endif ... }
but how to I handle same in iOS?