Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Notification Channels: The Complicated ...

Daniel Lew
September 05, 2017

Android Notification Channels: The Complicated Parts

Talk given to GDG Twin Cities.

Daniel Lew

September 05, 2017
Tweet

More Decks by Daniel Lew

Other Decks in Programming

Transcript

  1. Noises v2 • Metadata • Priority • Categories • People

    • Do not Disturb interruptions • Hiding on lock screen
  2. User Control App Control Importance Sound Vibration Light Show on

    lock screen Show badges on launcher Bypass "Do Not Disturb” Channel Name Channel Description
  3. Importance IMPORTANCE_HIGH Make sound and pop on screen IMPORTANCE_DEFAULT Make

    sound IMPORTANCE_LOW No sound IMPORTANCE_NONE No sound or visual interruption
  4. val channel = NotificationChannel("news", “News", NotificationManager.IMPORTANCE_DEFAULT)
 channel.description = "News and

    weather"
 channel.setShowBadge(false)
 
 val manager = context.getSystemService(NotificationManager::class.java)
 manager.createNotificationChannel(channel)
  5. val channel = NotificationChannel("news", “News", NotificationManager.IMPORTANCE_DEFAULT)
 channel.description = "News and

    weather"
 channel.setShowBadge(false)
 
 val manager = context.getSystemService(NotificationManager::class.java)
 manager.createNotificationChannel(channel)
  6. Timing • Create channels at… • Startup • First notification

    • Create all channels at once • Channel creation is idempotent
  7. Notification Groups val summaryNotification = NotificationCompat.Builder(context, "news")
 ...
 .setGroupSummary(true)
 .setGroup("myGroup")


    .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY)
 .build()
 
 val childNotification = NotificationCompat.Builder(context, "news")
 ...
 .setGroupSummary(false)
 .setGroup("myGroup")
 .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY)
 .build()
  8. Channels Break Groups • One group fails when channel disabled

    • Group-per-channel creates too many rows • Group-per-channel creates too many noises
  9. Trello’s Setup Name Importance Summary Launcher Badge? Mentions HIGH Yes

    Yes Due Soon DEFAULT Yes Yes Boards LOW No Yes Cards LOW No Yes Comments LOW No Yes Memberships LOW No Yes New Cards LOW No Yes Attachments MIN No No