[flutter_local_notifications] Add "selectable" property for AndroidNotificationDetails to disable click actions on the notification#2331
Conversation
…lick actions on the notification
MaikuB
left a comment
There was a problem hiding this comment.
Thanks for the PR. Left a couple of comments on there. Could you take a look?
| .setAutoCancel(BooleanUtils.getValue(notificationDetails.autoCancel)) | ||
| .setContentIntent(pendingIntent) | ||
| .setContentIntent( | ||
| BooleanUtils.getValue(notificationDetails.selectable) |
There was a problem hiding this comment.
Compared to other parts of the code, I don't believe you should be using BooleanUtils.getValue(). That is for coalescing null values to false. The null values would happen when introducing new fields/properties and there are scheduled notifications kept in shared preferences. With the changes introduced in the PR, my understanding is that null selectable value be coalesced to true instead of false
| /// disabling click actions on the notification. | ||
| /// | ||
| /// The default value is `true`. | ||
| final bool selectable; |
There was a problem hiding this comment.
- Can you update the example app to include a scenario that makes use of this?
- I assume the
onSelectNotificationcallback won't fire. Can you confirm? If so, can you update the API docs to explicitly add mention of this. Some developers may not realise the implication based on reading what's there
|
@tranleo148 I saw a notification that updated your branch. In case you missed it, I requested changes on this PR a while back. Are you going to be able to take a look? |
This PR introduces a new option to disable click actions on notifications from Flutter. In Android, disabling click actions on a notification is achieved by setting the contentIntent to null when building the notification. Currently, there is no option in Flutter to disable the click action.
To address this, I have added a new
selectableproperty that allows developers to control whether the notification is selectable or not. When selectable is set to false, thecontentIntentwill be set tonull, disabling click actions on the notification.The default value of
selectableistrue, ensuring that existing behavior is not affected unless explicitly changed.This change is backward-compatible and will not affect notifications unless the new property is utilized.