6
I'm currently developing an app for Android that uses the NotificationListenerService, which requires that the user will enable notification access for my app under Setting -> Security -> Notification Access.
My question is that can I redirect the user to this place so they will enable it? So far I only managed to direct them to Setting -> Security window.
Also, is it possible to first check if the user enabled notification access for my app already and only then redirect them?
For Flutter
After a long search, I found the solution that will show the intended notification settings.
This is only for Flutter.
I found an app_settings plugin. Just add it in pubspec.yaml and install it.
After that just one line of code.
RaisedButton(
onPressed: () {
// AppSettings.openLocationSettings();
AppSettings.openNotificationSettings();
// openWIFISettings();
},
)
For Java
To open the settings for a specific channel, you can use ACTION_CHANNEL_NOTIFICATION_SETTINGS:
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName())
.putExtra(Settings.EXTRA_CHANNEL_ID, yourChannelId);
startActivity(intent);
Using ACTION_APP_NOTIFICATION_SETTINGS will open settings of list all channels of the app:
Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
startActivity(intent);
For Notification check, you can use "areNotificationEnabled" method. You can read at below doc/ https://developer.android.com/reference/android/support/v4/app/NotificationManagerCompat.html#areNotificationsEnabled()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With