Add remaning notification snippets for d.android.com#933
Conversation
Change-Id: I5a9d083affc9ec7b9be5542a23933f694450a2b3
There was a problem hiding this comment.
Code Review
This pull request introduces several Android notification features and styles to the Compose snippets, including progress style, call style (incoming, ongoing, screening), notification permission requests, notification channels, and chat bubbles. The review feedback highlights two critical issues: first, performing side effects directly within the notificationChannels composable function is an anti-pattern that should be managed with LaunchedEffect and user-initiated triggers; second, bubble notifications require publishing the sharing shortcut via ShortcutManagerCompat.pushDynamicShortcut to function correctly.
Change-Id: Id506798fc81383ec724f7a2be400ce04e3e025b2
| val descriptionText = stringResource(R.string.channel_description) | ||
|
|
||
| // [START android_notification_channel_create] | ||
| androidx.compose.runtime.LaunchedEffect(Unit) { |
There was a problem hiding this comment.
Should this be done every time the composable launches again? This feels like something that should happen in once off in the Application Subclass of an app.
There was a problem hiding this comment.
right, this shouldn't be a composable at all. removing that annotation and just passing in context. Extracting the notification channel settings action in that method into a separate method. Thanks
| mChannel.description = descriptionText | ||
| // Register the channel with the system. You can't change the importance | ||
| // or other notification behaviors after this. | ||
| val notificationManager = |
There was a problem hiding this comment.
Is there a warning on this line about capturing context?
There was a problem hiding this comment.
none. Is that your expectation as a lint in Android Studio?
Change-Id: I8a55aeddd0f55fe1383bc2defe7204cc53160578
Change-Id: I5a9d083affc9ec7b9be5542a23933f694450a2b3
Snippets for