Professional Documents
Culture Documents
● What’s different?
○ Easier integration
○ All new features will be FCM only!
Registration for Push
Play Services
Backend
FirebaseInstanceIdService
Slack API
Slack Android Client
Push flight plan
Slack Push
Server
FirebaseMessagingService
SlackMessagingService
What’s in a push (Part I: Google Bits)
{
"to":
"e_a8VzsygpY:APA91bGGx4-LyXb1o8YJyO8Vdswf4Z1NGIZwh2hV06
Xx_bx1JCx4Lcd1W-Q8mG6wX8IYLods19BpVfsl23YHoHgqJpMbbPa70
xVZcNdzl0GMzzV4pzOrJe",
"priority": "high",
"data": { … }
}
What’s in a push (Part I: Google Bits)
{
"to":
"e_a8VzsygpY:APA91bGGx4-LyXb1o8YJyO8Vdswf4Z1NGIZwh2hV06
Xx_bx1JCx4Lcd1W-Q8mG6wX8IYLods19BpVfsl23YHoHgqJpMbbPa70
xVZcNdzl0GMzzV4pzOrJe",
"priority": "high",
"data": { … }
}
What’s in a push (Part I: Google Bits)
{
"to":
"e_a8VzsygpY:APA91bGGx4-LyXb1o8YJyO8Vdswf4Z1NGIZwh2hV06
Xx_bx1JCx4Lcd1W-Q8mG6wX8IYLods19BpVfsl23YHoHgqJpMbbPa70
xVZcNdzl0GMzzV4pzOrJe",
"priority": "high",
"data": { … }
}
"data": {
"sound": "b2.mp3",
"badge": 1,
"payload_version": "3",
"timestamp": "1469635289.000006",
"author_display_name": "Kodos Rigellian",
"author_avatar": "...",
"message": "hi",
"recent_messages": { … }
}
What’s in a push (Part II: Slack Bits)
"data": {
"sound": "b2.mp3",
"badge": 1,
"payload_version": "3",
"timestamp": "1469635289.000006",
"author_display_name": "Kodos Rigellian",
"author_avatar": "...",
"message": "hi",
"recent_messages": { … }
}
Building a Notification
What to build and post with?
● NotificationCompat.Builder
○ Provides setters for each component of the notification
○ Can use anything exposed by it safely regardless of OS version
● NotificationManagerCompat
○ Posts built notifications using
notify(int id, Notification notification)
Basic Notification Example
builder.setContentTitle(title)
.setContentText(text)
.setColor(color)
.setSmallIcon(R.drawable.ic_notification_24dp)
.setLargeIcon(avatarBitmap)
.setWhen(dateTime.getMillis());
notificationManager.notify(id, builder.build());
Basic Notification Example
builder.setContentTitle(title)
.setContentText(text)
.setColor(color)
.setSmallIcon(R.drawable.ic_notification_24dp)
.setLargeIcon(avatarBitmap)
.setWhen(dateTime.getMillis());
notificationManager.notify(id, builder.build());
Basic Notification Example
builder.setContentTitle(title)
.setContentText(text)
.setColor(color)
.setSmallIcon(R.drawable.ic_notification_24dp)
.setLargeIcon(avatarBitmap)
.setWhen(dateTime.getMillis());
notificationManager.notify(id, builder.build());
Basic Notification Example
builder.setContentTitle(title)
.setContentText(text)
.setColor(color)
.setSmallIcon(R.drawable.ic_notification_24dp)
.setLargeIcon(avatarBitmap)
.setWhen(dateTime.getMillis());
notificationManager.notify(id, builder.build());
Basic Notification Example
builder.setContentTitle(title)
.setContentText(text)
.setColor(color)
.setSmallIcon(R.drawable.ic_notification_24dp)
.setLargeIcon(avatarBitmap)
.setWhen(dateTime.getMillis());
notificationManager.notify(id, builder.build());
Basic Notification Example
builder.setContentTitle(title)
.setContentText(text)
.setColor(color)
.setSmallIcon(R.drawable.ic_notification_24dp)
.setLargeIcon(avatarBitmap)
.setWhen(dateTime.getMillis());
notificationManager.notify(id, builder.build());
Basic Notification Example
builder.setContentTitle(title)
.setContentText(text)
.setColor(color)
.setSmallIcon(R.drawable.ic_notification_24dp)
.setLargeIcon(avatarBitmap)
.setWhen(dateTime.getMillis());
notificationManager.notify(id, builder.build());
BigTextStyle
builder.setContentTitle(title)
.setContentText(text)
…
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(text)
.setSummaryText(account.getTeamName()));
BigTextStyle
builder.setContentTitle(title)
.setContentText(text)
…
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(text)
.setSummaryText(account.getTeamName()));
BigTextStyle
builder.setContentTitle(title)
.setContentText(text)
…
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(text)
.setSummaryText(account.getTeamName()));
BigTextStyle
builder.setContentTitle(title)
.setContentText(text)
…
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(text)
.setSummaryText(account.getTeamName()));
BigTextStyle
builder.setContentTitle(title)
.setContentText(text)
…
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(text)
.setSummaryText(account.getTeamName()));
MessagingStyle
MessagingStyle messagingStyle = new MessagingStyle("Mike")
.setConversationTitle(contentTitle);
builder.setContentTitle(title)
.setContentText(text)
…
.setSubText(account.getTeamName())
.setStyle(messagingStyle);
MessagingStyle
MessagingStyle messagingStyle = new MessagingStyle("Mike")
.setConversationTitle(contentTitle);
builder.setContentTitle(title)
.setContentText(text)
…
.setSubText(account.getTeamName())
.setStyle(messagingStyle);
MessagingStyle
MessagingStyle messagingStyle = new MessagingStyle("Mike")
.setConversationTitle(contentTitle);
builder.setContentTitle(title)
.setContentText(text)
…
.setSubText(account.getTeamName())
.setStyle(messagingStyle);
MessagingStyle
MessagingStyle messagingStyle = new MessagingStyle("Mike")
.setConversationTitle(contentTitle);
builder.setContentTitle(title)
.setContentText(text)
…
.setSubText(account.getTeamName())
.setStyle(messagingStyle);
MessagingStyle
MessagingStyle messagingStyle = new MessagingStyle("Mike")
.setConversationTitle(contentTitle);
builder.setContentTitle(title)
.setContentText(text)
…
.setSubText(account.getTeamName())
.setStyle(messagingStyle);
MessagingStyle
MessagingStyle messagingStyle = new MessagingStyle("Mike")
.setConversationTitle(contentTitle);
builder.setContentTitle(title)
.setContentText(text)
…
.setSubText(account.getTeamName())
.setStyle(messagingStyle);
Still with us?
Grouping Notifications
● A group consists of:
○ A set of one or more individual notifications
○ A single summary notification
■ Made by calling setGroupSummary(true)
id=1000 id=1999
groupKey=”MyGroup” groupKey=”MyGroup”
isGroupSummary=false isGroupSummary=true
text=”My first message” text=”My first message”
Grouping Notification Example
id=1000 id=1999
groupKey=”MyGroup” groupKey=”MyGroup”
isGroupSummary=false isGroupSummary=true
text=”My first message” text=”My first message”
id=1001 id=1999
groupKey=”MyGroup” groupKey=”MyGroup”
isGroupSummary=false isGroupSummary=true
text=”My second message” text=”2 new messages”
Wear + N and up Devices See These Pre-N Devices See The Most
as a Group Recently Posted Summary Only!
Grouping Visualized
Summary on KitKat Grouped on Nougat
Group Summaries Continued
● Build using stored notifications you’ve seen before
○ SharedPref/DB recommended as mentioned earlier
● Don’t forget to handle the user entering from the launcher icon or
recent app list!
Clearing Notifications
id=1000
clear(1000)
groupKey=”MyGroup” clear(1001)
isGroupSummary=false
text=”My first message”
id=1001 id=1999
groupKey=”MyGroup” groupKey=”MyGroup”
isGroupSummary=false isGroupSummary=true
text=”My second message” text=”2 new messages”
Clearing Notifications
id=1000
clear(1999)
groupKey=”MyGroup”
isGroupSummary=false
text=”My first message”
id=1001 id=1999
groupKey=”MyGroup” groupKey=”MyGroup”
isGroupSummary=false isGroupSummary=true
text=”My second message” text=”2 new messages”
Clearing Notifications
builder
.setContentIntent(userClickPendingIntent)
.setDeleteIntent(dismissPendingIntent)
Don’t forget to set these on both your individual notifications as well as the
group summary if present!
Reply Action
// Remote input instance to fetch data from the user
RemoteInput remoteInput =
new RemoteInput.Builder(KEY_REPLY_TEXT)
.setLabel(replyLabelString)
.setChoices(/* string array */)
.build();
● Information to record
○ FCM message id
○ Internal unique id from your backend for this particular push
data {
isTest: true
id: <server generated id>
}