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 Slide

  2. Goal
    • Inform users

    • …Without annoying them

    View Slide

  3. Noises
    • Sound




    View Slide

  4. Noises
    • Sound

    • Vibration


    View Slide

  5. Noises
    • Sound

    • Vibration

    • Light

    View Slide

  6. Noises v2
    • Metadata

    • Priority

    • Categories

    • People

    • Do not Disturb interruptions

    • Hiding on lock screen

    View Slide

  7. Android Oreo
    • Notification badges on launcher

    • Channels

    View Slide

  8. View Slide

  9. Channels give users control

    View Slide

  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

    View Slide

  11. targetSdkVersion 26
    ==
    Channels

    View Slide

  12. View Slide

  13. Measure Twice, Cut Once

    View Slide

  14. How Many Channels?

    View Slide

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

    View Slide

  16. Notification Groups

    View Slide

  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

    View Slide

  18. Custom Noise
    • Sound

    • Vibration

    • Light

    View Slide

  19. Bells and Whistles
    • Badges on launcher

    • Bypass “do not disturb”

    View Slide

  20. Playing Dirty
    • Can delete & recreate channels

    • Users will know

    • Will annoy users

    View Slide

  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)

    View Slide

  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)

    View Slide

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

    .setThis()
    .setThat()

    .etc()

    .build()

    View Slide

  24. Timing
    • Create channels at…

    • Startup

    • First notification

    • Create all channels at once

    • Channel creation is idempotent

    View Slide

  25. Inform users…
    ...WITHOUT annoying them

    View Slide

  26. How to annoy users without
    really trying

    View Slide

  27. Too Many Sounds

    View Slide

  28. Too Many Rows

    View Slide

  29. Notification Bundles
    1-3 notifications 4+ notifications

    View Slide

  30. Notification Bundles
    Pros Cons
    Easy

    Works across channels
    Many noises

    Only on Nougat+

    View Slide

  31. Notification Groups
    1 notification 2+ notifications

    View Slide

  32. Notification Groups

    View Slide

  33. Notification Groups
    Pros Cons
    Few notifications

    Few noises
    Extra work

    View Slide

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

    View Slide

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

    • Group-per-channel creates too many rows

    • Group-per-channel creates too many noises

    View Slide

  36. Channel Dilemma
    Bundling Groups
    Fewer rows

    Many noises
    Many rows

    Fewer noises

    View Slide

  37. Channel Solution
    • Channel should either…

    • Have a group summary

    • Be IMPORTANCE_LOW or lower

    View Slide

  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

    View Slide

  39. Odds and Ends

    View Slide

  40. Remove Notification Settings

    View Slide

  41. Remove Notification Settings Intent

    View Slide

  42. Listen to ACTION_LOCALE_CHANGED

    View Slide

  43. Use setAlertOnlyOnce()

    View Slide

  44. Summary
    • Embrace channels

    • Choose good defaults

    • Don’t annoy users

    View Slide

  45. Thank You!
    • danlew.net

    • @danlew42

    View Slide