Slide 1

Slide 1 text

Rich Android Notifications @waliahimanshu

Slide 2

Slide 2 text

Topics • Why Use? • Types of notifications • API Behaviour changes • Best practices & Pitfalls

Slide 3

Slide 3 text

Why ? Decrease in mindshare Growth, engagement and retention 1 2

Slide 4

Slide 4 text

Types of notification Transactional Non-transactional 1.opt-out 2.opt-in

Slide 5

Slide 5 text

Types of notification Non-transactional •opt-out •Opt-in

Slide 6

Slide 6 text

API Behaviour changes

Slide 7

Slide 7 text

Android 5 L setPriority() setVisibility()

Slide 8

Slide 8 text

•Inline replies from notification tray •Bundling •Support for Custom notifications •areNotificationsEnabled() Android 7 N

Slide 9

Slide 9 text

Inline replies Android N 7 Notification<— Action <—RemoteInput val remoteInput = RemoteInput.Builder(EXTRA_COMMENT) .setLabel(replyLabel) .build() val replyAction: Action = NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, pendingIntent) .addRemoteInput(remoteInput) .setAllowGeneratedReplies(true) .build() notificationCompatBuilder .addAction(replyAction)

Slide 10

Slide 10 text

Inline replies Android N 7 Action Pending intent ? •Activity •Service or BroadcastReceiver

Slide 11

Slide 11 text

Android N 7 Updating your notification val messagingStyle = NotificationCompat.MessagingStyle.extractMessagingStyleFromNotification( notification) // Add new message. messagingStyle.addMessage(replyCharSequence, currentTimeMillis(), null as Person?) // Updates and push Notification // Updates and pushes active Notification val updatedNotification = notificationCompatBuilder // Adds a line and comment below content in Notification .setRemoteInputHistory(arrayOf(comment)) .build()

Slide 12

Slide 12 text

Android N 7 Bundling builder.setGroup(groupKey) builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) builder.setGroup(groupKey) builder.setGroupSummary(true) builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) Summary Notification

Slide 13

Slide 13 text

Android N 7 •DecoratedCustomViewStyle •DecoratedMediaCustomViewStyle Support for custom notifications

Slide 14

Slide 14 text

•Channels •Changing channel settings -> Prohibited •Deleting & re-creating -> Revealed Android O 8 •Channel groups

Slide 15

Slide 15 text

Channel off? getNotificationChannel()/getNotificationChannels() getSound(),getVibration() and getImportance() getImportance() == IMPORTANCE_NONE // O isBlocked () // added in P Android O 8

Slide 16

Slide 16 text

Notification badge Android O 8

Slide 17

Slide 17 text

Android O 8 •Time-out for notification (setTimeoutAfter(long)) •setColorized() •setByPassDnd()

Slide 18

Slide 18 text

sender = Person.Builder() .setName("Me MacDonald") .setKey("1234567890") .setUri(“tel:1234567890") .setBot(true) .setIcon(IconCompat.createWithResource(context, R.drawable.me_macdonald)) .build() NotificationCompat.MessagingStyle(sender) .addMessage("Check this out!", Date().time, sender) .setBuilder(notificationBuilder) Android P 9 val message = Notification.MessagingStyle.Message(message, time, sender) .setData("image/", imageUri) Focus on display

Slide 19

Slide 19 text

val messagingStyle = MessagingStyle(messagingStyleCommsAppData.m .setConversationTitle("Group title") .setGroupConversation(true) Android P 9

Slide 20

Slide 20 text

Android 10 API 29 val remoteInput = RemoteInput.Builder(BigPictureSocialIntentService.EXTRA_COMMENT) .setLabel(replyLabel) // List of quick response choices from ML // .setChoices(possiblePostResponses) .build() val replyAction = NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .setAllowGeneratedReplies(true) .build() // Adds additional actions specified above. .addAction(replyAction) .setAllowSystemGeneratedContextualActions(true) Smart Replies

Slide 21

Slide 21 text

Smart reply and media style

Slide 22

Slide 22 text

Android 10 API 29

Slide 23

Slide 23 text

Android 10 API 29 Bubbles (preview)

Slide 24

Slide 24 text

Best practices

Slide 25

Slide 25 text

•Segment your users •Take the time of day into account •Actionable •Group and Prioritise

Slide 26

Slide 26 text

•In-App’s settings screen •Handle failure scenarios •Cancel notifications on sign-out

Slide 27

Slide 27 text

Pitfalls

Slide 28

Slide 28 text

•Don’t try this at home……test…ing Pitfalls •Do not use distinct small icon •Abuse notificationsEnabled()

Slide 29

Slide 29 text

•Notification icon (consider dark mode) •Avoid Custom view for notifications •large_icon 64dp * 64dp •big_picture 284dp * 416dp Pitfalls

Slide 30

Slide 30 text

Pitfalls •One channel •Avoid notification fatigue (Digital wellbeing)

Slide 31

Slide 31 text

Thank You

Slide 32

Slide 32 text

Extra / Bonus

Slide 33

Slide 33 text

Priority Order

Slide 34

Slide 34 text

Notification styles Big TextStyle Big PictureStyle

Slide 35

Slide 35 text

Notification styles Inbox Style Message Style Media Style

Slide 36

Slide 36 text

Building notification val builder = NotificationCompat.Builder(this, notificationChannelId).apply { setSmallIcon(R.drawable.ic_launcher) .setContentTitle("title") .setContentText("text") }

Slide 37

Slide 37 text

Building notification .setContentIntent(notifyPendingIntent) .setColor(R.color.colorPrimary)) .addAction(snoozeAction) .addAction(dismissAction)

Slide 38

Slide 38 text

Android N 7/25 Bundling