Slide 1

Slide 1 text

The evolution of notifications @JeremMartinez

Slide 2

Slide 2 text

What is a notification? 1

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

“A notification is a message you can display to the user outside of your application's normal UI. […] Both the notification area and the notification drawer are system-controlled areas that the user can view at any time.” Definition

Slide 5

Slide 5 text

“A notification is a message you can display to the user outside of your application's normal UI. […] Both the notification area and the notification drawer are system-controlled areas that the user can view at any time.” Definition

Slide 6

Slide 6 text

Awareness I exist!

Slide 7

Slide 7 text

Quick access and actions!

Slide 8

Slide 8 text

History 2

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

13:37 Content title Content text Gingerbread (2.3)

Slide 13

Slide 13 text

Content title Content text SubText 13:37 Ice Scream Sandwich (4.0)

Slide 14

Slide 14 text

Content title Content text SubText Action 13:37 Jelly Bean (4.1|2|3)

Slide 15

Slide 15 text

Content title Content text SubText Action 13:37 Kitkat (4.4)

Slide 16

Slide 16 text

Content title Content text SubText 13:37 ACTION Lollipop (5.0)

Slide 17

Slide 17 text

Content title Content text SubText 13:37 ACTION Marshmallow (6.0)

Slide 18

Slide 18 text

Content title Content text SubText ACTION 13:37 Android Makers Nougat (7.0)

Slide 19

Slide 19 text

Android

Slide 20

Slide 20 text

Content title Content text SubText ACTION 13:37 Android Makers

Slide 21

Slide 21 text

Be a good citizen 3

Slide 22

Slide 22 text

Letters Telegrams Phone calls SMS Emails Batman

Slide 23

Slide 23 text

Letters Telegrams Phone calls SMS Emails Batman [SPAM]

Slide 24

Slide 24 text

1

Slide 25

Slide 25 text

Disruptions through the day

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Deletion of information by mistake

Slide 29

Slide 29 text

Info forgotten Bad timing

Slide 30

Slide 30 text

1 Amount Priority Metadata Category

Slide 31

Slide 31 text

1 Amount Priority Metadata Category

Slide 32

Slide 32 text

1 Amount Priority Metadata Category Importance

Slide 33

Slide 33 text

Categorize 4

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

FUN PAIN

Slide 36

Slide 36 text

URGENT NON-URGENT FUN PAIN

Slide 37

Slide 37 text

URGENT NON-URGENT FUN PAIN

Slide 38

Slide 38 text

URGENT FUN

Slide 39

Slide 39 text

VIP of our life Urgent & Fun

Slide 40

Slide 40 text

URGENT NON-URGENT FUN PAIN

Slide 41

Slide 41 text

FUN NON-URGENT

Slide 42

Slide 42 text

Procrastination Non-urgent & Fun

Slide 43

Slide 43 text

URGENT NON-URGENT FUN PAIN

Slide 44

Slide 44 text

URGENT PAIN

Slide 45

Slide 45 text

Livelihood Urgent & Painful

Slide 46

Slide 46 text

URGENT NON-URGENT FUN PAIN

Slide 47

Slide 47 text

NON-URGENT PAIN

Slide 48

Slide 48 text

Nagging Non-urgent & Painful

Slide 49

Slide 49 text

2 main principles to evaluate a notification

Slide 50

Slide 50 text

Be relevant Help yourself with context

Slide 51

Slide 51 text

Be legitimate Don’t lie about urgency

Slide 52

Slide 52 text

Use case

Slide 53

Slide 53 text

Scheduled

Slide 54

Slide 54 text

Scheduled

Slide 55

Slide 55 text

Always up to date

Slide 56

Slide 56 text

Scheduled

Slide 57

Slide 57 text

Urgent

Slide 58

Slide 58 text

Triggering 5

Slide 59

Slide 59 text

Notification notification = new NotificationCompat.Builder(this). setSmallIcon(R.drawable.ic_notification). setContentTitle("Title"). setContentText("Text"). build(); NotificationManagerCompat.from(this).notify(12345, notification);

Slide 60

Slide 60 text

Notification notification = new NotificationCompat.Builder(this). setSmallIcon(R.drawable.ic_notification). setContentTitle("Title"). setContentText("Text"). build(); NotificationManagerCompat.from(this).notify(12345, notification);

Slide 61

Slide 61 text

1. Local events e.g. downloads, updates, posting a tweet

Slide 62

Slide 62 text

2. Scheduled AlarmManager

Slide 63

Slide 63 text

context.getSystemService(AlarmManager.class);

Slide 64

Slide 64 text

alarmManager.setExact(type, triggerAtMillis, operation);

Slide 65

Slide 65 text

alarmManager.setExact(type, triggerAtMillis, operation);

Slide 66

Slide 66 text

if (BuildUtils.hasMarshmallow()) { alarmManager.setExactAndAllowWhileIdle(type, millis, operation); } else if (BuildUtils.hasKitKat()) { alarmManager.setExact(type, millis, operation); } else { alarmManager.set(type, millis, operation); } setExact

Slide 67

Slide 67 text

if (BuildUtils.hasMarshmallow()) { alarmManager.setExactAndAllowWhileIdle(type, millis, operation); } else if (BuildUtils.hasKitKat()) { alarmManager.setExact(type, millis, operation); } else { alarmManager.set(type, millis, operation); } setExact

Slide 68

Slide 68 text

if (BuildUtils.hasMarshmallow()) { alarmManager.setExactAndAllowWhileIdle(type, millis, operation); } else if (BuildUtils.hasKitKat()) { alarmManager.setExact(type, millis, operation); } else { alarmManager.set(type, millis, operation); } setExact

Slide 69

Slide 69 text

if (BuildUtils.hasMarshmallow()) { alarmManager.setExactAndAllowWhileIdle(type, millis, operation); } else if (BuildUtils.hasKitKat()) { alarmManager.setExact(type, millis, operation); } else { alarmManager.set(type, millis, operation); } setExact

Slide 70

Slide 70 text

alarmManager.setExact(type, triggerAtMillis, operation);

Slide 71

Slide 71 text

alarmManager.setExact( , triggerAtMillis, operation); type

Slide 72

Slide 72 text

type AlarmManager.RTC System.currentTimeMillis() AlarmManager.RTC_WAKEUP | time since boot including sleep

Slide 73

Slide 73 text

type AlarmManager.ELAPSED_REALTIME SystemClock.elapsedRealtime() AlarmManager.ELAPSED_REALTIME_WAKEUP | wall clock time in UTC

Slide 74

Slide 74 text

alarmManager.setExact( , triggerAtMillis, operation); type

Slide 75

Slide 75 text

alarmManager.setExact( , , operation); type triggerAtMillis

Slide 76

Slide 76 text

alarmManager.setExact( , , ); type triggerAtMillis operation

Slide 77

Slide 77 text

operation public static PendingIntent getBroadcast( … ) public static PendingIntent getActivity( … ) public static PendingIntent getService( … ) PendingIntent

Slide 78

Slide 78 text

Is it that simple ?

Slide 79

Slide 79 text

PendingIntent.getActivity( context, 123, intent, FLAG_UPDATE_CURRENT); final Intent intent = new Intent(this, MainActivity.class); PendingIntent.getActivity( context, 123, intent, FLAG_UPDATE_CURRENT); = ?

Slide 80

Slide 80 text

PendingIntent.getActivity( context, 123, intent, FLAG_UPDATE_CURRENT); final Intent intent = new Intent(this, MainActivity.class); PendingIntent.getActivity( context, 123, intent, FLAG_UPDATE_CURRENT);

Slide 81

Slide 81 text

PendingIntent.getActivity( context, 1234, intent, FLAG_UPDATE_CURRENT); final Intent intent = new Intent(this, MainActivity.class); PendingIntent.getActivity( context, 1235, intent, FLAG_UPDATE_CURRENT); = ?

Slide 82

Slide 82 text

PendingIntent.getActivity( context, 1234, intent, FLAG_UPDATE_CURRENT); final Intent intent = new Intent(this, MainActivity.class); PendingIntent.getActivity( context, 1235, intent, FLAG_UPDATE_CURRENT);

Slide 83

Slide 83 text

PendingIntent.getActivity( context, 123, intent1, FLAG_UPDATE_CURRENT); final Intent intent1 = new Intent(this, MainActivity.class); PendingIntent.getActivity( context, 123, intent2, FLAG_UPDATE_CURRENT); = ? final Intent intent2 = new Intent(this, MainActivity.class);

Slide 84

Slide 84 text

PendingIntent.getActivity( context, 123, intent1, FLAG_UPDATE_CURRENT); PendingIntent.getActivity( context, 123, intent2, FLAG_UPDATE_CURRENT); final Intent intent1 = new Intent(this, MainActivity.class); final Intent intent2 = new Intent(this, MainActivity.class);

Slide 85

Slide 85 text

PendingIntent.getActivity( context, 123, intent1, FLAG_UPDATE_CURRENT); final Intent intent1 = new Intent(this, MainActivity.class). putExtra("extra1", "extra1"); PendingIntent.getActivity( context, 123, intent2, FLAG_UPDATE_CURRENT); = ? final Intent intent2 = new Intent(this, MainActivity.class). putExtra(“extra2", "extra2");

Slide 86

Slide 86 text

PendingIntent.getActivity( context, 123, intent1, FLAG_UPDATE_CURRENT); final Intent intent1 = new Intent(this, MainActivity.class). putExtra("extra1", "extra1"); PendingIntent.getActivity( context, 123, intent2, FLAG_UPDATE_CURRENT); final Intent intent2 = new Intent(this, MainActivity.class). putExtra(“extra2", "extra2");

Slide 87

Slide 87 text

PendingIntent.getActivity( context, 123, intent1, FLAG_UPDATE_CURRENT); final Intent intent1 = new Intent(this, MainActivity.class). addCategory(Intent.CATEGORY_APP_BROWSER); PendingIntent.getActivity( context, 123, intent2, FLAG_UPDATE_CURRENT); = ? final Intent intent2 = new Intent(this, MainActivity.class). addCategory(Intent.CATEGORY_APP_CALCULATOR);

Slide 88

Slide 88 text

PendingIntent.getActivity( context, 123, intent1, FLAG_UPDATE_CURRENT); final Intent intent1 = new Intent(this, MainActivity.class). addCategory(Intent.CATEGORY_APP_BROWSER); PendingIntent.getActivity( context, 123, intent2, FLAG_UPDATE_CURRENT); final Intent intent2 = new Intent(this, MainActivity.class). addCategory(Intent.CATEGORY_APP_CALCULATOR);

Slide 89

Slide 89 text

public boolean filterEquals(Intent other) { if (other == null) { return false; } if (!Objects.equals(this.mAction, other.mAction)) return false; if (!Objects.equals(this.mData, other.mData)) return false; if (!Objects.equals(this.mType, other.mType)) return false; if (!Objects.equals(this.mPackage, other.mPackage)) return false; if (!Objects.equals(this.mComponent, other.mComponent)) return false; if (!Objects.equals(this.mCategories, other.mCategories)) return false; return true; }

Slide 90

Slide 90 text

- Survive app upgrade - Survive reboot How long ? Be future proof !

Slide 91

Slide 91 text

3. Realtime Push notifications: GCM & Firebase

Slide 92

Slide 92 text

- Use extensively group - Be careful about marketing abuse - Don’t forget to remove notifications

Slide 93

Slide 93 text

Snooze

Slide 94

Slide 94 text

Time-out

Slide 95

Slide 95 text

Styling 6

Slide 96

Slide 96 text

BigPictureStyle BigTextStyle InboxStyle MediaStyle MessagingStyle Notification.Style

Slide 97

Slide 97 text

Default

Slide 98

Slide 98 text

BigText

Slide 99

Slide 99 text

BigPicture

Slide 100

Slide 100 text

Media

Slide 101

Slide 101 text

Notification.Style DecoratedCustomViewStyle

Slide 102

Slide 102 text

RemoteViews Run in another process

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

Avoid RemoteViews Prefer default styling or span

Slide 105

Slide 105 text

Spanned everything! Very powerful API — Available everywhere

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

SpannableString delayedSpanned = new SpannableString(delayed); delayedSpanned.setSpan(new StrikethroughSpan(), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); delayedSpanned.setSpan(new ForegroundColorSpan(textColor), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE);

Slide 108

Slide 108 text

SpannableString delayedSpanned = new SpannableString(delayed); delayedSpanned.setSpan(new StrikethroughSpan(), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); delayedSpanned.setSpan(new ForegroundColorSpan(textColor), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE);

Slide 109

Slide 109 text

SpannableString delayedSpanned = new SpannableString(delayed); delayedSpanned.setSpan(new StrikethroughSpan(), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); delayedSpanned.setSpan(new ForegroundColorSpan(textColor), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE);

Slide 110

Slide 110 text

delayedSpanned.setSpan(new ForegroundColorSpan(textColor), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); SpannableString delayedSpanned = new SpannableString(delayed); delayedSpanned.setSpan(new StrikethroughSpan(), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); textView.setText(getString(R.string.travelTextWithDelay, // time, // delayedSpanned));

Slide 111

Slide 111 text

delayedSpanned.setSpan(new ForegroundColorSpan(textColor), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); SpannableString delayedSpanned = new SpannableString(delayed); delayedSpanned.setSpan(new StrikethroughSpan(), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); textView.setText(getString(R.string.travelTextWithDelay, // time, // delayedSpanned));

Slide 112

Slide 112 text

delayedSpanned.setSpan(new ForegroundColorSpan(textColor), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); SpannableString delayedSpanned = new SpannableString(delayed); delayedSpanned.setSpan(new StrikethroughSpan(), // 0, delayedSpanned.length(), // Spanned.SPAN_INCLUSIVE_INCLUSIVE); textView.setText(TagFormatter.from(this, R.string.travelTextWithDelay). with("arrival_time", time). with("estimated_arrival_time", delayedSpanned). format()); textView.setText(getString(R.string.travelTextWithDelay, // time, // delayedSpanned));

Slide 113

Slide 113 text

Other tips 7

Slide 114

Slide 114 text

Transient Be able to find the same info elsewhere in the app

Slide 115

Slide 115 text

Be patient Wait for the content

Slide 116

Slide 116 text

Clean up Delete outdated notification

Slide 117

Slide 117 text

No content

Slide 118

Slide 118 text

Think VIP Help Android to order

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

Think multi-devices Synchronize notifications

Slide 121

Slide 121 text

Conclusion 8 @JeremMartinez