push notification

75
06.12.2016 Recep Düzdemir | Software Infrastructure Gizem Akman | Software Infrastructure Push Notification

Upload: software-infrastructure

Post on 09-Jan-2017

102 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Push Notification

06.12.2016Recep Düzdemir | Software Infrastructure

Gizem Akman | Software Infrastructure

Push Notification

Page 2: Push Notification

Push Notification

Push notification is the delivery of information from a software application to a computing device without a specific request from the client.

Message may contain notification, data or both.

Page 3: Push Notification
Page 4: Push Notification

Push Notification Lifecycle

RegisterStore Registration TokenSend Message

Page 5: Push Notification

Message Parameters

Page 6: Push Notification

Message Parameters (Cont’d)

Page 7: Push Notification

Message Payload

Page 8: Push Notification

Notification Parameters

Page 9: Push Notification

Firebase Cloud Messaging

• HTTP API• XMPP API

Page 10: Push Notification

FCM HTTP API

• @ https://gcm-http.googleapis.com/gcm/send• syncronous• supports multiple recipients and topics• no delivery receipt• unidirectional

Page 11: Push Notification

FCM HTTP Response Codes

Page 12: Push Notification

FCM HTTP Errors

Page 13: Push Notification

FCM HTTP Errors (Cont’d)

Page 14: Push Notification

FCM HTTP Errors (Cont’d)

Page 15: Push Notification

FCM XMPP API

• @ fcm-xmpp.googleapis.com:5235• asyncronous• supports single recipient only• bidirectional• returns delivery receipt

Page 16: Push Notification

FCM XMPP Errors

Page 17: Push Notification

FCM XMPP Errors (Cont’d)

Page 18: Push Notification

FCM XMPP Errors (Cont’d)

Page 19: Push Notification

Apple Push Notification Service (APNs)

• Legacy API ( TCP)• HTTP/2 API

Page 20: Push Notification

APNs Binary API

• @gateway.push.apple.com:2195• supports up to 2KB payload• separate feedback service @ feedback.push.apple.com:2196• returns no response in case of success• returns an error response in case of failure and immediately

closes the connection

Page 21: Push Notification

APNs Binary API Response Format

Page 22: Push Notification

APNs HTTP/2 API

• @api.push.apple.com:443• supports up to 4KB payload

Page 23: Push Notification

APNs HTTP/2 Response Format

Page 24: Push Notification

APNs HTTP/2 Error Reasons

Page 25: Push Notification

APNs HTTP/2 Error Reasons (Cont’d)

Page 26: Push Notification

iOS vs Android

Page 27: Push Notification

Q&A

Page 28: Push Notification
Page 29: Push Notification

IOS 10 RICH NOTIFICATIONS

In iOS 10 notifications are becoming a key part of Apple's mobile operating system, and one of the primary way that users interact with apps.

Page 30: Push Notification

IOS 10 RICH NOTIFICATIONS

As part of the new UserNotifications framework, Apple has given us the ability to make notifications that contain images, sound, video, or even custom content generated on the device.

Much of this capability comes via three new features showcased at Worldwide Developers Conference(WWDC): media attachments, notification service extensions, and notification content extensions.

Including media in your push notification can increase the open rate.

Page 31: Push Notification

What’s new in iOS 10 Notifications?

Notifications can now contain images and gifs

Page 32: Push Notification

What’s new in iOS 10 Notifications?

It is now possible to add images and gifs to notifications.

These images or gifs can be loaded either from the resources of your app, or from a remote URL.

iOS will first download the image or gif and then display the notification.

Page 33: Push Notification

What’s new in iOS 10 Notifications?

Notifications can contain videos

Notifications can contain videos up to 50 megabytes in size.

Page 34: Push Notification

What’s new in iOS 10 Notifications?

Notifications can be interactive

Notifications can now contain buttons. Users can use action buttons to interact with notifications.

As with earlier versions of iOS, buttons can also be used to open your app and take specific actions. But unlike earlier versions, actions buttons are much more easily seen since they don't require a left-swipe on the notification.

Page 35: Push Notification

Why Media Attachments Are Awesome

Media attachments open up new opportunities for user engagement with our apps.

Before, we were limited to just a couple lines of text; we had to rely on the user opening the app to do anything more.

This is a win-win for app makers and users. App makers get to deliver more compelling content in their notifications, and users get more choice in their level of notification interaction.

Page 36: Push Notification

How They Work

Media attachments work slightly different between local notifications and remote notifications.

In the case of a local notification, its media attachment must contain the URL of a file on disk at the time that an app creates the notification.

The file is copied when the notification is scheduled, and that file is delivered along with the notification. No extra effort is required.

Page 37: Push Notification

How They Work

For a remote notification, a remote notification service delivers information about the media attachment as part of the APNS notification payload.

This includes the attachment URL, which, importantly, does not have to be the URL of a file already on the device.

However, iOS 10 will not automatically deliver an attachment with a notification if that attachment is not stored locally.

Apple’s solution to this problem is something called the Notification Service Extension.

Page 38: Push Notification

Notification Service Extension

Before IOS 10

Page 39: Push Notification

Notification Service Extension

IOS 10

Page 40: Push Notification

Notification Service Extension

Service extension lets you customize the content of a remote notification before it is delivered to the user.

You could use the extension to decrypt an encrypted data block or to download images associated with the notification.

Page 41: Push Notification

Notification Service Extension

At 4KB in size, a remote notification’s payload is too small to deliver a media attachment file itself.

Instead, we define an attachment URL in the remote notification payload.

Once a device receives the remote notification payload for our app, the app’s service extension gets the chance to download the file at the URL and attach it to the notification before the device displays the notification to the user.

Page 42: Push Notification

Notification Service Extension

How to add service extension to your application?

Page 43: Push Notification

Notification Service Extension

Add a new target to your project

Page 44: Push Notification

Notification Service Extension

When you created the Service Extension, Xcode created the NotificationService.swift file and an Info.plist file.

Page 45: Push Notification

Notification Service Extension

We use the first function to download the content from the URL and add it to the notification. We should also handle network errors here.

We use the second function to handle the case where the first function runs out of time (as determined by iOS).

Page 46: Push Notification

Notification Service Extension

How does iOS know which notifications to intercept?

Page 47: Push Notification

Notification Service Extension

Notification Payload

The mutable-content fields tells iOS that the notification has content that can be changed by a service extension before delivery

Page 48: Push Notification

What if we don’t just want to serve up simple media files?

What if we want to generate custom content?

Page 49: Push Notification

Notification Content Extension

Notification Content Extension let you provide custom UI for your notifications.

A Notification Content Extension gives us a chance to process a notification and supply new content to the notification before it is displayed to the user.

Page 50: Push Notification

Notification Content Extension

Most important things:

Custom views Support for remote and local notifications No interaction with views (possible only with

notification actions) Respond to notification actions

Page 51: Push Notification

Notification Content Extension

How to add content extension to your application?

Page 52: Push Notification

Notification Content Extension

Add a new target to your project

Page 53: Push Notification

Notification Content Extension

MainInterface.storyboard : we will desing our notification UI in this.

NotificationViewController.swift : a UIViewController subclass that will enable us to update our custom interface.

When you created the Content Extension, Xcode created the NotificationViewController.swift file, a MainInterface.storyboard file and an Info.plist file.

Page 54: Push Notification

Notification Content Extension

How does the notification content extension work?

Page 55: Push Notification

Notification Content Extension

Set an identifier for UNNotificationExtensionCategory key in extension's Info.plist:

Page 56: Push Notification

Notification Content Extension

Remote Notifications

Local Notifications

{ aps: { category: ‘myNotificationCategory' } }

Page 57: Push Notification

Notification Content Extension

Page 58: Push Notification

Notification Content Extension

We may also implement optional functions that handle action button presses or display media playback controls.

How to add a custom action?

Page 59: Push Notification

Notification Actions

You can add up to four actions and each action is encompassed in a ‘category’.

Page 60: Push Notification

Demo

Page 61: Push Notification

Android N Notifications

Notifications are become an important part of every Android application and it is an intelligent way to re-engage users with the installed apps.

Effectively used notifications will help application to get returning users.

Page 62: Push Notification

Android N Notifications

To provide a better user experience, notifications on Android N have received a visual refresh, improved support for custom views, and expanded functionality in the forms of Direct Reply, a new MessagingStyle, and bundled notifications.

Page 63: Push Notification

Android N Notifications

The first and most obvious change is that the default look and feel of notifications has significantly changed.

Many of the fields that were spread around the notifications have been collapsed into a new header row with your app’s icon and name anchoring the notification.

This change ensured that the title, text, and large icon are given the most amount of space possible and, as a result, notifications are generally slightly larger now and easier to read.

Page 64: Push Notification

Android N Notifications

Page 65: Push Notification

Android N Notifications

Notification actions have also received a redesign and are now in a visually separate bar below the notification.

Page 66: Push Notification

Direct Reply

While notification actions have already been able to launch an Activity or do background work with a Service or BroadcastReceiver, Direct Reply allows you to build an action that directly receives text input inline with the notification actions.

Page 67: Push Notification

Direct Reply

Page 68: Push Notification

Android N Notifications

If you’re building a messaging app and expect back and forth conversations, you should use MessagingStyle and append the additional message to it.

Page 69: Push Notification

Messaging Style

Page 70: Push Notification

Messaging Style

Page 71: Push Notification

Bundled Notifications

Bundled notifications that appear grouped when a group ID has been set for each notification.

Page 72: Push Notification

Bundled Notifications

We can also display actions for notifications that are bundled.

Page 73: Push Notification

Custom View Notifications

We can now use custom views for notifications These can be for both collapsed and expanded notification layouts.

Page 74: Push Notification

Demo

Page 75: Push Notification

Q&A