Reputation: 479
My issue is that I am not sure what String key to use to check for Notification permissions. For key
"com.google.android.c2dm.permission.RECEIVE"
this code always returns true, even if I remove the permission from my Manifest:
int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), "com.google.android.c2dm.permission.RECEIVE");
if (permissionCheck==PackageManager.PERMISSION_GRANTED) {
Log.d("granted","TRUE");
}
I also tried other permission strings like 'mypkg.permission.C2D_MESSAGE'.
If this is because the Notification permission in the system is considered "normal" and not "dangerous", then how do I detect if the user has disabled Notifications for my app in phone settings (like attached image)?
Upvotes: 4
Views: 3001
Reputation: 10009
You don't need permissions for notification check.
You can use NotificationManagerCompat.areNotificationsEnabled() method of the support library.
You can use this on API 19+, and for the APIs below this, it always returns true
.
Upvotes: 5