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

Android Notification Channels: The Complicated Parts

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. Android Notification Channels:
    The Complicated Parts
    Dan Lew

    View full-size slide

  2. Goal
    • Inform users

    • …Without annoying them

    View full-size slide

  3. Noises
    • Sound




    View full-size slide

  4. Noises
    • Sound

    • Vibration


    View full-size slide

  5. Noises
    • Sound

    • Vibration

    • Light

    View full-size slide

  6. Noises v2
    • Metadata

    • Priority

    • Categories

    • People

    • Do not Disturb interruptions

    • Hiding on lock screen

    View full-size slide

  7. Android Oreo
    • Notification badges on launcher

    • Channels

    View full-size slide

  8. Channels give users control

    View full-size slide

  9. User Control App Control
    Importance

    Sound

    Vibration

    Light

    Show on lock screen

    Show badges on launcher

    Bypass "Do Not Disturb”
    Channel Name

    Channel Description

    View full-size slide

  10. targetSdkVersion 26
    ==
    Channels

    View full-size slide

  11. Measure Twice, Cut Once

    View full-size slide

  12. How Many Channels?

    View full-size slide

  13. Trello Channel Overview
    Important Minor Temporary
    Mentions New Cards Attachments
    Due Soon Cards
    Boards
    Comments
    Memberships

    View full-size slide

  14. Notification Groups

    View full-size slide

  15. Importance
    IMPORTANCE_HIGH Make sound and pop on screen
    IMPORTANCE_DEFAULT Make sound
    IMPORTANCE_LOW No sound
    IMPORTANCE_NONE No sound or visual interruption

    View full-size slide

  16. Custom Noise
    • Sound

    • Vibration

    • Light

    View full-size slide

  17. Bells and Whistles
    • Badges on launcher

    • Bypass “do not disturb”

    View full-size slide

  18. Playing Dirty
    • Can delete & recreate channels

    • Users will know

    • Will annoy users

    View full-size slide

  19. 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)

    View full-size slide

  20. 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)

    View full-size slide

  21. val notification = NotificationCompat.Builder(context, "news")

    .setThis()
    .setThat()

    .etc()

    .build()

    View full-size slide

  22. Timing
    • Create channels at…

    • Startup

    • First notification

    • Create all channels at once

    • Channel creation is idempotent

    View full-size slide

  23. Inform users…
    ...WITHOUT annoying them

    View full-size slide

  24. How to annoy users without
    really trying

    View full-size slide

  25. Too Many Sounds

    View full-size slide

  26. Too Many Rows

    View full-size slide

  27. Notification Bundles
    1-3 notifications 4+ notifications

    View full-size slide

  28. Notification Bundles
    Pros Cons
    Easy

    Works across channels
    Many noises

    Only on Nougat+

    View full-size slide

  29. Notification Groups
    1 notification 2+ notifications

    View full-size slide

  30. Notification Groups

    View full-size slide

  31. Notification Groups
    Pros Cons
    Few notifications

    Few noises
    Extra work

    View full-size slide

  32. 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()

    View full-size slide

  33. Channels Break Groups
    • One group fails when channel disabled

    • Group-per-channel creates too many rows

    • Group-per-channel creates too many noises

    View full-size slide

  34. Channel Dilemma
    Bundling Groups
    Fewer rows

    Many noises
    Many rows

    Fewer noises

    View full-size slide

  35. Channel Solution
    • Channel should either…

    • Have a group summary

    • Be IMPORTANCE_LOW or lower

    View full-size slide

  36. 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

    View full-size slide

  37. Odds and Ends

    View full-size slide

  38. Remove Notification Settings

    View full-size slide

  39. Remove Notification Settings Intent

    View full-size slide

  40. Listen to ACTION_LOCALE_CHANGED

    View full-size slide

  41. Use setAlertOnlyOnce()

    View full-size slide

  42. Summary
    • Embrace channels

    • Choose good defaults

    • Don’t annoy users

    View full-size slide

  43. Thank You!
    • danlew.net

    • @danlew42

    View full-size slide