[MUSIC PLAYING]
JINGYU SHI: Hi, everyone.
Welcome to Modern Android Notifications.
My name is Jingyu.
I'm a developer advocate in the Partner Developer Team.
PAUL MATTHEWS: And I'm Paul Matthews.
I'm a partner developer advocate in London.
So three years ago on this stage,
Chris Wren, an Android engineer on the system UI,
gave this quote, and it's a brilliant one.
"Don't annoy the user.
Respect them.
Empower them.
Delight them.
Connect them to the people they care about."
And this is still very much true today.
So we will look at channels and how you can use them
in your app, what's new in notifications, and finally,
Digital Wellbeing, but first, how to respect your users.
So respect your users' attention.
Don't annoy the user.
Respect them.
Some useful tips-- so do respect the user's settings.
So if they've communicated to you in your app
that they want a certain setting for your notifications,
then you should respect that.
Don't try and override it.
Don't try and ignore it.
You should check that the notifications you're sending
are not blocked, that they do still want
to hear these notifications.
And finally, if you are capable in your app,
you should backup any settings that they've
told you about notifications.
And you should make sure they're synced
over installs and over devices.
You should use well-structured notifications
in your app, so making use of the styles that we provide,
such as MessagingStyle, InboxStyle, BigPictureStyle.
And you should make sure that your notifications
are relevant and timely.
Great example is using high priority FCM messages
to ensure that the user gets the notification when you intend
them to get your notification.
And prioritize posting the notifications first, and then
making them look even better, so downloading
assets and that kind of thing.
Some don'ts, some basic don'ts--
don't just send these notifications
and kind of forget about them.
So we really want you to use the platform features that
are there to help you.
For instance, auto cancel, making sure
that your notifications disappear when they should.
Time outs, is a notification really
relevant after four hours?
And synchronizing across the devices--
if you know that your user uses your app on multiple devices,
like tablets and desktops, you should try and synchronize
notifications that they dismiss on one
or read on one across others.
Don't send notifications that are not actionable.
The point of notifications is that they're there to be used.
By definition, the user wants to know
something, which means they generally need to do something.
So don't send them a notification
that just tells them hey, we sync
some stuff in the background.
This is not the best use of notifications.
And finally, don't annoy the user.
So when you post a notification to them,
you should use alert once, and make sure
that they're not getting buzzed like crazy,
as they're standing up on stage presenting about notifications.
And you should make sure that the group notification
behavior is representative of what you want.
So if you're a chat app, maybe children group notification
behavior, or summary if you're something else.
So respect the user.
Otherwise, they might just turn off your notifications.
And then you've got no way of communicating to them.
They might choose to uninstall your app, which
would be far worse.
There are some platform features that deliberately enable
notifications being turned off.
For instance, you can see here the notifications being posted.
And the users maybe keep swiping it away.
And so now in P, we prompt the user.
Do you really care about this notification?
Do you really want to see this content?
This acts on channels.
So if you're not describing your channels correctly,
then this can lead to some confusion,
and perhaps some lost notifications
from the user's perspective.
So let's talk more about notification channels.
They provide granular control to your notifications
for the user.
So you should empower the user.
And clearly, channels are the way to empower them.
So let's look at how to use them.
Well first of all, they're now required on all apps.
They're required on API 26.
And that should be everywhere prevalent now.
They help the user categorize--
they help you categorize your notifications that help
the user to interact with them.
But more on that soon.
And finally, they allow the user to customize their settings.
So the user has the final say.
So if you think something is important
and they don't think it is, they can tell you this.
So let's look at the best practices.
Again, you should allow the users
to manage their notifications through the channel creation.
You should allow them to maybe deep link into settings
to change these things.
If they are expressing an interest
of working with your notification channels,
perhaps they want to be able to change
the importance of something.
So setting the right importance level for a notification
channel seems like an obvious one,
but it's so easy to overlook.
And finally, user settings--
you should respect the user settings, as we said earlier.
But back them up where you can, and don't try and abuse them
by deleting and recreating.
Other don'ts are only using one channel.
This is a clear notification smell, if you like.
If you've only got one channel in your application,
there's probably something else you need to be looking at.
If you provide poor descriptions for users
so that they don't really understand
what the purpose of a channel is,
then they're not going to be able to make the best
decisions.
Or if you use wrong or blocked channels,
then this is probably, you know, they're
trying to communicate to you that they
don't like this content.
And you should respect that.
And finally, spamming the user with notification channels
is just not the best way to proceed.
So choosing your channels can really
help, choosing your channels carefully.
You really should think of the user
when you create your channels, not your application, not
your architecture.
Think of the user and how they might
want to interact with your app.
For instance, it's a bad idea to try and create
notification channels around your importance level
that you find important.
So hey, this is a really high priority thing.
This isn't what notification channels are for.
You should group them around categories
of notifications, for instance, tagging in a photo,
or liked posts.
Let the user communicate back to you
how they see that type of notification.
You should also think about creating notifications when
there is more control needed.
For instance, if I'm on a chat app.
And I've got a general channel for all chat notifications
coming in.
But then I express an interest in controlling,
like, a family chat group, you should create
a channel at that point, and allow the user to dive deeper
and have more finely grained control.
And finally, lazily creating, so this comes back
to not creating too many channels or groups.
And that is if Jingyu never receives a direct message
through your app, maybe you don't need
to create the channel for that.
And then the user can provide feedback to you
to say, look, this is useful or this isn't useful.
And you should listen to that.
So in Android P, we added broadcasts
for listening in to blocking or changing state
of your notification channels.
You should understand those.
And you should react to them.
You should maybe back them up, so that the next time you
create a channel on a different device, it makes sense.
And finally, you can query these APIs at runtime
also to find out how the user interacts with your channels.
So now, look at what's new in notifications.
JINGYU SHI: Thank you, Paul.
Let's now look at what else is new in notifications
on Android 9.
First, we added some visual updates
to make the notifications easier to read and scan through.
As you probably noticed, we added more padding
single notification.
And we went back to using the rounded corners
at the top and bottom.
The other improvement that we really love
is this smooth app opening animation
that you're seeing here on the slide.
Instead of closing the notification
and opening the app, now the notification
transforms smoothly into the app, which speeds up
the transition more than twice.
And you might ask, what do you need to do to have this?
All you need to do is to make sure
that you are starting your activity directly,
and your activity starts quickly.
Since for most users, the notifications
they care about the most are the ones connecting them
with the people they care.
So we enhanced our MessagingStyle, our messaging
experience, by adding a new person
class once you use API 28.
And if you're using MessagingStyle in notification,
you can see that we have now moved the people's avatar
to the left of the notification.
And you can set that avatar by using the setIcon method.
We also added support for images and stickers
in the messaging notification.
By using site data, you can add image
in your messaging notification directly.
The other feature that I love on Android is direct reply.
But sometimes when I'm replying to a notification,
I would accidentally tap on the notification,
and that will open the app.
And my response is lost.
But on Android 9 you can help the user with this.
By retrieving the draft from this extra,
you can populate the response in your app.
So make the user experience better, delight them.
If you already support Smart Reply in your app,
we highly recommend that you use the setChoices API
to also display them in your notification.
Instead of replying to the notification,
user can now just tap one of them to reply.
OK, here's an example we have for creating
MessagingStyle notification using the new APIs.
So first, we're going to create an instance, a person instance,
here.
So we're going to use the person builder.
As you can see, we are setting the names, the URI,
the icon for this person.
And this is going to represent the sender in a message.
And then we're going to pass that to this message
that we're creating here.
As you can see, we're passing the instance of the person,
not like before, where we were passing
the name of that person.
And in this message, we also want to include the image.
So we're using the setData method to include that image.
And then after that, we're adding this message
with another message.
So we're adding two messages into this MessagingStyle
notification.
And then we're setting the style into our notification.
OK, so here's a quick summary of some of the dos and don'ts when
you're using MessagingStyle.
First, please use MessagingStyle for messages.
And this also applies for if you're
building for Android Auto or Android Wear.
If you're sending messaging notifications,
please use MessagingStyle.
In the past, we've seen developers
switching between MessagingStyle and some other styles,
like BigPictureStyle, in order to create that big image
expansion presentation.
But now with setData method you don't need to do that.
You can just use MessagingStyle.
And this will create a consistent experience
for the user.
And it's always good to add that icon for the people
in the notification.
So we highly recommend that you use setIcon to add that avatar.
But if you don't set the icon, we
will use the initial for the name for that person
to create that visual presentation.
And finally, if your app supports Smart Reply,
please add that into your notification,
so you are creating a better experience for the user.
And here's a few things that you want to avoid.
There are a lot of good reasons to auto
cancel a notification, in order to give the user a clean and up
to date notification jar.
But after user replies to a notification, a messaging
notification, this is not one of those cases.
You would want to keep that notification there.
So if user want to return to this conversation
and reply afterwards.
So please don't cancel that.
And let the users swipe away when they're
finished with the conversation.
The other bad behavior that we've seen in the past
is some developers are setting this empty name,
in order to achieve a visual presentation.
But on Android 9, please don't do that.
There are two reasons.
One is because it will break on Android 9, on the presentation.
And the other reason is because a person without a name
is not a real person.
So up until now, we will talk about how
you can reach the user--
how you can help your user connect with people
they care about, and how you can make your notification a better
experience for the user.
But I want to hit pause here, and look at app usage
from the other side.
Since as much as I want to get that notification
from my friend and family, I still
need time away from the device.
So to help users with this, we announced the Digital Wellbeing
at I/O this year.
If you have a [INAUDIBLE] device running Android 9,
I highly recommend that you download it from the Play
Store, and sign up for beta.
So this is what Digital Wellbeing will show us.
It provides an overview of our app usage
and provides dashboards that shows our time spending
on each app, and the number of notifications
that we've received.
I personally love using Digital Wellbeing to learn
where I'm spending my time.
But sometimes I would find that one or two apps
are sending me a lot of notifications unexpectedly.
So one question you might have is,
how are these notifications counted?
Since this is still in beta, the counting method may change.
But the goal is to track user interruptions.
So in general, any newly created notifications
are counted as one.
And any updates that's visible to the user
are also counted as one, which means
if you're sending a notification to the block channel, that
is not counted here.
So in this case, I saw this app is sending me
lots of notifications.
So I got curious.
I went into the dashboard.
And I opened that to see the hourly breakdown.
And as you can see here, I got notifications every hour
that day.
And even at 4:00 AM in the morning,
I got eight notifications.
So if these notifications are high importance,
I would be woken up in the middle of the night.
But thankfully, that's not the case.
But if these notifications are push notifications,
and they are sent using high priority FCM message, which
means this app is constantly waking up a deep dose device.
If I want to have good battery in the morning,
I might just uninstall this app.
But for now, I will turn on DND, Do Not Disturb,
so that I don't get disturbed.
Digital Wellbeing also provides ways for users
to disconnect and reduce interruption.
And on Pixel 3, you can even turn on DND
by simply flip your device, which is super convenient.
But what if this is a super important notification
that the user actually wants to receive?
So for those, here's a few advice for you.
First, set the right category to your notification.
As we can see here in the do not disturb setting,
user can choose what to block and what to allow.
And they can set exceptions on calls, messages, reminders,
and events.
If your notification belongs to one of them,
please tag your notification as such.
Here are listed a few categories which
correspond to these exceptions on the other side.
As I said, if your notification belongs
to one of these categories, please let us
know by tagging them.
The other advice that we have is if this
is a notification coming from another person, then
please tag your notification.
As you can see here in the do not disturb setting,
user can choose who they want to get a notify from,
from their contacts.
So please add that person in your notification,
and add the associated URI, if possible.
Doing this will allow you to bypass do not disturb.
But you should always remember that when user turn on
do not disturb, they really don't want to be disturbed.
So if you're sending a notification that's
not expected, that will really annoy them.
So please don't abuse these APIs, which this brings us
back to the quote we had at the beginning,
where we're saying whenever you're sending a notification,
please keep this in mind.
Don't annoy the user, respect them, empower them,
delight them, and connect them to the people they care about.
Thank you.
[APPLAUSE]
[MUSIC PLAYING]