Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QT6 request permittion (notifications in my case)?
Forum Updated to NodeBB v4.3 + New Features

QT6 request permittion (notifications in my case)?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 1 Posters 295 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shokarta
    wrote on last edited by
    #1

    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++
    1 Reply Last reply
    0
    • S Offline
      S Offline
      shokarta
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved