Android Notification Channels: The Complicated Parts

D225ebf0faa666ac7655cc7e4689283c?s=47 Daniel Lew
September 05, 2017

Android Notification Channels: The Complicated Parts

Talk given to GDG Twin Cities.

D225ebf0faa666ac7655cc7e4689283c?s=128

Daniel Lew

September 05, 2017
Tweet

Transcript

  1. Android Notification Channels: The Complicated Parts Dan Lew

  2. Goal • Inform users • …Without annoying them

  3. Noises • Sound
 
 
 


  4. Noises • Sound • Vibration
 


  5. Noises • Sound • Vibration • Light

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

    • Do not Disturb interruptions • Hiding on lock screen
  7. Android Oreo • Notification badges on launcher • Channels

  8. None
  9. Channels give users control

  10. User Control App Control Importance Sound Vibration Light Show on

    lock screen Show badges on launcher Bypass "Do Not Disturb” Channel Name Channel Description
  11. targetSdkVersion 26 == Channels

  12. None
  13. Measure Twice, Cut Once

  14. How Many Channels?

  15. Trello Channel Overview Important Minor Temporary Mentions New Cards Attachments

    Due Soon Cards Boards Comments Memberships
  16. Notification Groups

  17. Importance IMPORTANCE_HIGH Make sound and pop on screen IMPORTANCE_DEFAULT Make

    sound IMPORTANCE_LOW No sound IMPORTANCE_NONE No sound or visual interruption
  18. Custom Noise • Sound • Vibration • Light

  19. Bells and Whistles • Badges on launcher • Bypass “do

    not disturb”
  20. Playing Dirty • Can delete & recreate channels • Users

    will know • Will annoy users
  21. 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)
  22. 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)
  23. val notification = NotificationCompat.Builder(context, "news")
 .setThis() .setThat()
 .etc()
 .build()

  24. Timing • Create channels at… • Startup • First notification

    • Create all channels at once • Channel creation is idempotent
  25. Inform users… ...WITHOUT annoying them

  26. How to annoy users without really trying

  27. Too Many Sounds

  28. Too Many Rows

  29. Notification Bundles 1-3 notifications 4+ notifications

  30. Notification Bundles Pros Cons Easy Works across channels Many noises

    Only on Nougat+
  31. Notification Groups 1 notification 2+ notifications

  32. Notification Groups

  33. Notification Groups Pros Cons Few notifications Few noises Extra work

  34. 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()
  35. Channels Break Groups • One group fails when channel disabled

    • Group-per-channel creates too many rows • Group-per-channel creates too many noises
  36. Channel Dilemma Bundling Groups Fewer rows Many noises Many rows

    Fewer noises
  37. Channel Solution • Channel should either… • Have a group

    summary • Be IMPORTANCE_LOW or lower
  38. 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
  39. Odds and Ends

  40. Remove Notification Settings

  41. Remove Notification Settings Intent

  42. Listen to ACTION_LOCALE_CHANGED

  43. Use setAlertOnlyOnce()

  44. Summary • Embrace channels • Choose good defaults • Don’t

    annoy users
  45. Thank You! • danlew.net • @danlew42