ID Android TechTalk Series #6 : Google Service and Gradle - Andrew Kurniadi

Post on 11-Jan-2017

312 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

Transcript

Firebase Cloud Messaging & AuthenticationAndrew Kurniadi, GDE

GCM

“a free service that enables developers to send messages between servers and client apps. This includes downstream messages from servers to client apps, and upstream messages from client

apps to servers.”

GCM == FCM ?

Why FCM?

● Registration and subscription retry logic handled by FCM SDK

● GCM will not get any new features● Google ❤� ❤� ❤� Firebase

Message Components

● Target● Options● Payload● Priority

Target { "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "notification" : { "body" : "Hello World. This is me Andrew", "title" : "Hello World", "icon" : "myicon" } }

Payload { "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...", "notification" : { "body" : "Hello World. This is me Andrew", "title" : "Hello World", "icon" : "myicon" }, "data" : { "City" : "Jakarta", "Provider" : "Cinema21" } }

2KBNotification Limit

4KBData Limit

Common Message Options● Collapsible Messages

○ Chat Messages○ Important message

● Non-Collapsible Messages○ Send-to-sync○ Ping

Priority{ "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",

"priority" : "normal", "notification" : { "body" : "Hello World. This is me Andrew", "title" : "Hello World", "icon" : "myicon" } }

Do I need to migrate from GCM?

● Google will continue to support GCM● No new Client-Side feature will be added to GCM

Services<service

// You only need to have this service if you want to handle the payload manually

android:name=".MyFirebaseMessagingService">

<intent-filter>

<action android:name="com.google.firebase.MESSAGING_EVENT"/>

</intent-filter>

</service>

<service

// Extends FirebaseInstanceIdService

android:name=".MyFirebaseInstanceIDService">

<intent-filter>

<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>

</intent-filter>

</service>

FirebaseInstanceIdService@Overridepublic void onTokenRefresh() { // Get updated InstanceID token. String refreshedToken = FirebaseInstanceId.getInstance().getToken(); Log.d(TAG, "Refreshed token: " + refreshedToken);

// TODO: Implement this method to send any registration to your app's servers. sendRegistrationToServer(refreshedToken);}

FirebaseMessagingService

● Handle background messages manually● Handle data payload● Send upstream messages● Receive message in foregrounded app

Code Demo

Firebase Authentication

How does it work?

Supported Authentication Method● Popular Services (Google, Facebook, Twitter, Github)● Email & Password● Anonymous Login● Custom Backend Auth

FirebaseUI Auth

● Drop-In solution● Customizable

Firebase Authentication SDK

● Implement Custom Flow● More Work

Terima Kasih

top related