63

I have read that it is necessary to ask the user for some permissions at runtime for API 23 and up. For example: android.permission.ACCESS_FINE_LOCATION. Is it necessary (or even possible) to ask for a runtime permission for using GCM/push notifications at runtime if API is 23 or higher?

I have tried using the requestPermissions method at runtime, but it doesn't seem to work (nothing happens) when I use it with any GCM/push notification related permissions.

I have the following permissions in my Manifest for this purpose:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<permission
    android:name="${applicationId}.permission.C2D_MESSAGE"
    android:protectionLevel="signature"/>

The only permission that the user knows of, is the ACCESS_FINE_LOCATION when downloading the app from Play Store. Shouldn't the user be able to choose whether or not they would allow push notifications?

halfer
  • 19,824
  • 17
  • 99
  • 186
Langkiller
  • 3,377
  • 13
  • 43
  • 72

1 Answers1

145

Actually the Push Notification permission lie in Normal Category Permission like INTERNET permission not in Dangerous Category Permission.

You don't have to ask for Push Notification permissions.

While Contacts/Locations are the Dangerous permissions because you are accessing user data.so always needed to ask to user to allow it.

Hope so you understand. https://developer.android.com/guide/topics/security/permissions.html

Umer Waqas
  • 1,794
  • 1
  • 12
  • 15
  • 2
    @Umer what is the name of permission in the "Normal Category" that enables Push Notifications? – Sergey Moshkov Dec 19 '16 at 13:59
  • You can receive Push Notifications , if you have Internet permission , Connected Internet and properly GCM Configuration . – Umer Waqas Dec 20 '16 at 06:11
  • That is a signature permission, and signature permissions are not part of the runtime permission system. They are granted automatically based upon signature matches. – keybee Feb 10 '17 at 16:29
  • So as its not a requirement to get permission by prompt, would it still be useful and user friendly to provide a prompt ... some how in react native? Thanks for the answer! – Michael Jan 23 '18 at 23:48
  • ACCESS_NOTIFICATION_POLICY :https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_NOTIFICATION_POLICY – s-hunter May 02 '18 at 16:59
  • Is this still true in 2019? Doesn't seem to me. – markus Sep 30 '19 at 11:25
  • @LukasPoustka API 32 is part of Android 12. I assume you meant Tiramisu respectively API level 33, right? – alexanderdavide May 18 '22 at 08:29
  • 4
    @alexanderdavide: Of course! Android 13 (API 33) introduces a new way similar to iOS - a permission is necessary to use push notifications: https://developer.android.com/about/versions/13/changes/notification-permission – Lukas Poustka May 19 '22 at 12:12
  • @LukasPoustka do you know how to support older versions pre 13 while implementing the new 13 sdk version? – Eenvincible Jul 25 '22 at 19:57
  • @Eenvincible If your targetSdk equals 33, notifications are by default still allowed for Android 12L and lower. Any extra steps necessary. – Lukas Poustka Jul 26 '22 at 18:54