notifee icon indicating copy to clipboard operation
notifee copied to clipboard

[Android] Quick Action always requires device to be unlocked on Android 12

Open ayau opened this issue 9 months ago • 14 comments

On Android 12+, quick actions are created with NotificationPendingIntent.createIntent which uses PendingIntent.getActivities https://github.com/invertase/notifee/blob/f78a56518b1fe0dab060e96c2a1f145e41b7363a/android/src/main/java/app/notifee/core/NotificationPendingIntent.java#L89-L94

According to Android documentation, a notification action that launches an activity requires the user to unlock their device.

If a notification action causes an app to launch an activity or send a direct reply, users must unlock the device before the app can invoke that notification action.

In this example from Android's documentation for creating a "Snooze" action, they're using PendingIntent.getBroadcast, which executes the snoozing without launching the activity, and doesn't require the user to unlock their phone.

Intent snoozeIntent = new Intent(this, MyBroadcastReceiver.class);
snoozeIntent.setAction(ACTION_SNOOZE);
snoozeIntent.putExtra(EXTRA_NOTIFICATION_ID, 0);
PendingIntent snoozePendingIntent =
        PendingIntent.getBroadcast(this, 0, snoozeIntent, 0);

NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
        .setSmallIcon(R.drawable.notification_icon)
        .setContentTitle("My notification")
        .setContentText("Hello World!")
        .setPriority(NotificationCompat.PRIORITY_DEFAULT)
        .setContentIntent(pendingIntent)
        .addAction(R.drawable.ic_snooze, getString(R.string.snooze),
                snoozePendingIntent);

A potential solution here may be to use BroadcastReceiver for quick actions that are not launching an activity? (i.e. have launchActivity and getMainComponent set to null) For my use case, I would like the user to be able to Snooze a notification, or "Mark as complete" without needing to unlock their phone.

P.S. Not sure if this is related but I've also noticed pressing any quick action automatically closes the notification drawer, even if I have autoCancel set to false, and launchActivity is null. This makes it harder for users to go through a list of notifications and press the "archive" action on each one since it keeps closing the drawer after each action.

ayau avatar Sep 18 '23 07:09 ayau

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Oct 16 '23 08:10 github-actions[bot]

This has not been fixed yet

ayau avatar Oct 22 '23 20:10 ayau

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Nov 19 '23 20:11 github-actions[bot]

I assume this is still relevant since there's not been a new release of Notifee since it was raised (haven't got time to check the behaviour directly right now, sorry! 🙏 )

liamjones avatar Nov 27 '23 11:11 liamjones

most likely still relevant then yes - still working my way to the surface to give this repo the polish it deserves but getting closer

mikehardy avatar Nov 28 '23 16:11 mikehardy

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Dec 26 '23 16:12 github-actions[bot]

Not stale

liamjones avatar Dec 27 '23 10:12 liamjones

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Jan 24 '24 12:01 github-actions[bot]

Not stale

pavelustenko avatar Jan 24 '24 13:01 pavelustenko

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Feb 21 '24 14:02 github-actions[bot]

still persists

pavelustenko avatar Feb 21 '24 14:02 pavelustenko

Need this for silent action triggers without opening the app itself.

ayonshafiul avatar Mar 20 '24 13:03 ayonshafiul

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Apr 17 '24 13:04 github-actions[bot]

not stale

ReemKrauss avatar Apr 17 '24 13:04 ReemKrauss

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar May 15 '24 15:05 github-actions[bot]

Not stale

liamjones avatar May 16 '24 07:05 liamjones