SlideShare a Scribd company logo
Introduction to
To develop a mobile application
What people think
To develop a mobile application
Reality
To develop a mobile application
Reality
Authentication
Database
Storage
Analytics
Crash Reporting
Push Notifications
Web Hosting
etc.
To develop a mobile application
Reality
Authentication
Database
Storage
Analytics
Crash Reporting
Push Notifications
Web Hosting
etc.
Authentication
Database
Storage
Analytics
Crash Reporting
Push Notifications
Web Hosting
etc.
To develop a mobile application
Backend Developer 1
System Admin
Backend Developer 2
To develop a mobile application
Reality
Authentication
Database
Storage
Analytics
Crash Reporting
Push Notifications
Web Hosting
etc.
To develop a mobile application
Authentication
Database
Storage
Analytics
Crash Reporting
Push Notifications
Web Hosting
etc.
To develop a mobile application
To develop a mobile application
REST? REST?
To develop a mobile application
Android SDK iOS SDK
With Firebase
•
Compact team: You don’t need to hire Backend engineers
•
Fast iteration
•
Scalable
•
Your team can sleep at night !
Firebase
Developers install firebase by including a library in their applications.
This library provides a data structure that is automatically
synchronised between all of your clients and with our servers.
if one client changes a piece of data, every other client observing
the same piece of data will be updated as well within milliseconds.
Firebase features
Custom server code
Security
Real time synchronization of data
Offline support
Supports various mobile and web platforms
Firebase - support
Firebase has support for the web, iOS, OS X, and Android.
In addition, it has a Node.js and a Java library designed for server-side use.
The Firebase web client supports all mainstream browsers (IE 7+, Firefox 3+,
Chrome, Safari, Opera, and major mobile web browsers), and it works on
any network connection.
Firebase features - Custom server code
Firebase fully support access from your backend servers.
When used in this configuration, you still get all of the benefits of
using Firebase as your data store (way less code, easier scaling,
real-time updates, etc.), while gaining the flexibility to run
whatever custom backend logic you need.
It has a Node.JS client, a Java Client and a REST API specifically
for this purpose.
This allows you to do your own data processing, custom
validation, etc. on your own servers while still relying on Firebase
for data storage and real-time propagation of updates.
Firebase features - First class security
Firebase is intended for business-critical applications, and it
take the safety of your data very seriously.
All of your data is stored redundantly and off-site backups
are made nightly.
Firebase features - Offline support
Firebase transparently reconnects to the Firebase servers as
soon as you regain connectivity.
In the meantime, all Firebase operations done locally by your
app will immediately fire events, regardless of network state, so
your app will continue functioning correctly.
Once connectivity is reestablished, you’ll receive the
appropriate set of events so that your client “catches up” with
the current server state, without you having to write any custom
code.
Firebase features - Real-time Synchronisation
Data updating speed of firebase is very fast.
Firebase is designed to be fast enough for high performance
real-time applications like network games.
It maintain persistent connections between clients and its
servers so that data can be pushed in both directions without
delay, and it’s servers are optimised for extremely low latencies.
Here comes the new
DEVELOP
GROW
EARN
Backend Services
Realtime Database
Authentication
Hosting
Storage
Cloud Messaging
Remote Config
App Quality Services
Test Lab for Android
Crash Reporting
Acquisition
Dynamic Links
Invites
AdWords
Re-Engagement
Notifications
App Indexing
In-app Ads
AdMob
Analytics
Firebase
Firebase
Firebase
Easy to read documentation
Firebase: Get Started
Firebase
•
Strongly Integrated with Android Studio 2.2
•
You can integrate Firebase with your app with just few clicks !
•
[Live Demo]
Authentication
•
Register / Login with
•
Email + Password
•
Google
•
Facebook
•
Twitter
•
GitHub
•
Email address verification
•
Password reset
Authentication
private FirebaseAuth mAuth;
// ...
mAuth = FirebaseAuth.getInstance();
Creating User
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new
OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult>
task) {
Log.d(TAG, "createUserWithEmail:onComplete:" +
task.isSuccessful());
if (!task.isSuccessful()) {
Toast.makeText(EmailPasswordActivity.this,
"Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
Logging In
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new
OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult>
task) {
Log.d(TAG, “signInWithEmail:onComplete:" +
task.isSuccessful());
if (!task.isSuccessful()) {
Toast.makeText(EmailPasswordActivity.this,
"Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
Sign Out
FirebaseAuth.getInstance().signOut();
Facebook Login
mCallbackManager = CallbackManager.Factory.create();
LoginButton loginButton = (LoginButton)
findViewById(R.id.button_facebook_login);
loginButton.setReadPermissions("email", "public_profile");
loginButton.registerCallback(mCallbackManager, new
FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.d(TAG, "facebook:onSuccess:" + loginResult);
handleFacebookAccessToken(loginResult.getAccessToken());
}
@Override
public void onCancel() { }
@Override
public void onError(FacebookException error) { }
});
Facebook Login
private void handleFacebookAccessToken(AccessToken token) {
Log.d(TAG, "handleFacebookAccessToken:" + token);
AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Log.w(TAG, "signInWithCredential", task.getException());
Toast.makeText(FacebookLoginActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
Realtime Database
•
Cloud-hosted NoSQL database
•
Synchronization & conflict resolution
•
Access directly from your app
Realtime Database
Realtime Database
// Write a message to the database
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("message");
myRef.setValue("Hello, World!");
Realtime Database
// Read from the database
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
String value = dataSnapshot.getValue(String.class);
Log.d(TAG, "Value is: " + value);
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
});
Storage
•
Easy file storage
•
Handles poor connectivity
Backed by & accessible from
•
Google Cloud Storage
Storage
FirebaseStorage storage = FirebaseStorage.getInstance();
Uploading a file
Uri file = Uri.fromFile(new File("path/to/images/rivers.jpg"));
StorageReference riversRef = storageRef.child("images/"+file.getLastPathSegment());
uploadTask = riversRef.putFile(file);
// Register observers to listen for when the download is done or if it fails
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size,
// content-type, and download URL.
Uri downloadUrl = taskSnapshot.getDownloadUrl();
}
});
Downloading a file
islandRef = storageRef.child("images/island.jpg");
File localFile = File.createTempFile("images", "jpg");
islandRef.getFile(localFile)
.addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
// Local temp file has been created
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
Hosting
•
Serve static assets
•
SSL by default
Hosting
Install the Firebase CLI
npm install –g firebase-tools
Initialize your app
$ firebase init
Add a file
Deploy your website
$ firebase deploy
Hosting
Install the Firebase CLI
npm install –g firebase-tools
Initialize your app
$ firebase init
Add a file
Deploy your website
$ firebase deploy
Remote Config
Dynamically configures
•
your app on-the-fly
•
[Live Demo]
Remote Config
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
Set default parameter value as a XML file in res/xml
Fetch new configurations with fetch() and replace the current one
Firebase
Cloud Messaging
•
Firebase Cloud Messaging (FCM)
•
Enable Push Notifications in just few LoCs
•
Build on top of GCM, switch to FCM !
•
See in details in the next session
Firebase
DEVELOP
GROW
EARN
Backend Services
Realtime Database
Authentication
Hosting
Storage
Cloud Messaging
Remote Config
App Quality Services
Test Lab for Android
Crash Reporting
Acquisition
Dynamic Links
Invites
AdWords
Re-Engagement
Notifications
App Indexing
In-app Ads
AdMob
Analytics
Crash Reporting
•
See crashes & impact
•
Version & OS drill-down
•
Integrated with Analytics
Crash Reporting
FirebaseCrash.report(new Exception("My first Android non-fatal error"));
FirebaseCrash.log("Activity created");
Basically just add dependency
compile 'com.google.firebase:firebase-crash:9.0.2'
Firebase
Test Lab
Test on the most popular
•
devices before you ship
•
Reports & screenshots
•
Robo & custom tests
Test Lab
In Action
Firebase
Firebase
Firebase
DEVELOP
GROW
EARN
Backend Services
Realtime Database
Authentication
Hosting
Storage
Cloud Messaging
Remote Config
App Quality Services
Test Lab for Android
Crash Reporting
Acquisition
Dynamic Links
Invites
AdWords
Re-Engagement
Notifications
App Indexing
In-app Ads
AdMob
Analytics
Dynamic Links
Customize different user experiences
•
via a single URL
•
Works across platforms
Preserves URL state, even through
•
app install flow
•
Analytics insights
Firebase
Firebase
Invites
•
Drop-in widget for app sharing
•
Supports SMS and Email
•
Recipient suggestions from Google
•
Built on Dynamic Links
Invites
Invites
private void onInviteClicked() {
Intent intent = new AppInviteInvitation
.IntentBuilder(getString(R.string.invitation_title))
.setMessage(getString(R.string.invitation_message))
.setDeepLink(Uri.parse(getString(R.string.invitation_deep_link)))
.setCustomImage(Uri.parse(getString(R.string.invitation_custom_image)))
.setCallToActionText(getString(R.string.invitation_cta))
.build();
startActivityForResult(intent, REQUEST_INVITE);
}
Invites
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode);
if (requestCode == REQUEST_INVITE) {
if (resultCode == RESULT_OK) {
// Get the invitation IDs of all sent messages
String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
for (String id : ids) {
Log.d(TAG, "onActivityResult: sent invitation " + id);
}
} else {
// Sending failed or it was canceled, show failure message to the user
// ...
}
}
}
App Indexing
•
Integrate with Google Search
•
Index app content
•
Boost search ranking
App Indexing
AdMob by Google
Engaging formats:
•
video, interstitial & native
•
1M+ apps using AdMob
•
Integrated with Firebase SDK
Analytics
•
Designed for apps
•
Event and user centric
•
Connects across Firebase
Firebase
Firebase
Firebase
Firebase
Firebase
Firebase
Firebase
Firebase
Firebase
Firebase
Pricing
DEVELOP
GROW
EARN
Backend Services
Realtime Database
Authentication
Hosting
Storage
Cloud Messaging
Remote Config
App Quality Services
Test Lab for Android
Crash Reporting
Acquisition
Dynamic Links
Invites
AdWords
Re-Engagement
Notifications
App Indexing
In-app Ads
AdMob
Analytics
Thank you

More Related Content

Firebase

  • 2. To develop a mobile application What people think
  • 3. To develop a mobile application Reality
  • 4. To develop a mobile application Reality Authentication Database Storage Analytics Crash Reporting Push Notifications Web Hosting etc.
  • 5. To develop a mobile application Reality Authentication Database Storage Analytics Crash Reporting Push Notifications Web Hosting etc.
  • 6. Authentication Database Storage Analytics Crash Reporting Push Notifications Web Hosting etc. To develop a mobile application Backend Developer 1 System Admin Backend Developer 2
  • 7. To develop a mobile application Reality Authentication Database Storage Analytics Crash Reporting Push Notifications Web Hosting etc.
  • 8. To develop a mobile application Authentication Database Storage Analytics Crash Reporting Push Notifications Web Hosting etc.
  • 9. To develop a mobile application
  • 10. To develop a mobile application REST? REST?
  • 11. To develop a mobile application Android SDK iOS SDK
  • 12. With Firebase • Compact team: You don’t need to hire Backend engineers • Fast iteration • Scalable • Your team can sleep at night !
  • 13. Firebase Developers install firebase by including a library in their applications. This library provides a data structure that is automatically synchronised between all of your clients and with our servers. if one client changes a piece of data, every other client observing the same piece of data will be updated as well within milliseconds.
  • 14. Firebase features Custom server code Security Real time synchronization of data Offline support Supports various mobile and web platforms
  • 15. Firebase - support Firebase has support for the web, iOS, OS X, and Android. In addition, it has a Node.js and a Java library designed for server-side use. The Firebase web client supports all mainstream browsers (IE 7+, Firefox 3+, Chrome, Safari, Opera, and major mobile web browsers), and it works on any network connection.
  • 16. Firebase features - Custom server code Firebase fully support access from your backend servers. When used in this configuration, you still get all of the benefits of using Firebase as your data store (way less code, easier scaling, real-time updates, etc.), while gaining the flexibility to run whatever custom backend logic you need. It has a Node.JS client, a Java Client and a REST API specifically for this purpose. This allows you to do your own data processing, custom validation, etc. on your own servers while still relying on Firebase for data storage and real-time propagation of updates.
  • 17. Firebase features - First class security Firebase is intended for business-critical applications, and it take the safety of your data very seriously. All of your data is stored redundantly and off-site backups are made nightly.
  • 18. Firebase features - Offline support Firebase transparently reconnects to the Firebase servers as soon as you regain connectivity. In the meantime, all Firebase operations done locally by your app will immediately fire events, regardless of network state, so your app will continue functioning correctly. Once connectivity is reestablished, you’ll receive the appropriate set of events so that your client “catches up” with the current server state, without you having to write any custom code.
  • 19. Firebase features - Real-time Synchronisation Data updating speed of firebase is very fast. Firebase is designed to be fast enough for high performance real-time applications like network games. It maintain persistent connections between clients and its servers so that data can be pushed in both directions without delay, and it’s servers are optimised for extremely low latencies.
  • 21. DEVELOP GROW EARN Backend Services Realtime Database Authentication Hosting Storage Cloud Messaging Remote Config App Quality Services Test Lab for Android Crash Reporting Acquisition Dynamic Links Invites AdWords Re-Engagement Notifications App Indexing In-app Ads AdMob Analytics
  • 25. Easy to read documentation
  • 27. Firebase • Strongly Integrated with Android Studio 2.2 • You can integrate Firebase with your app with just few clicks ! • [Live Demo]
  • 28. Authentication • Register / Login with • Email + Password • Google • Facebook • Twitter • GitHub • Email address verification • Password reset
  • 29. Authentication private FirebaseAuth mAuth; // ... mAuth = FirebaseAuth.getInstance();
  • 30. Creating User mAuth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful()); if (!task.isSuccessful()) { Toast.makeText(EmailPasswordActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } });
  • 31. Logging In mAuth.signInWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, “signInWithEmail:onComplete:" + task.isSuccessful()); if (!task.isSuccessful()) { Toast.makeText(EmailPasswordActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } });
  • 33. Facebook Login mCallbackManager = CallbackManager.Factory.create(); LoginButton loginButton = (LoginButton) findViewById(R.id.button_facebook_login); loginButton.setReadPermissions("email", "public_profile"); loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d(TAG, "facebook:onSuccess:" + loginResult); handleFacebookAccessToken(loginResult.getAccessToken()); } @Override public void onCancel() { } @Override public void onError(FacebookException error) { } });
  • 34. Facebook Login private void handleFacebookAccessToken(AccessToken token) { Log.d(TAG, "handleFacebookAccessToken:" + token); AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken()); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful()); // If sign in fails, display a message to the user. If sign in succeeds // the auth state listener will be notified and logic to handle the // signed in user can be handled in the listener. if (!task.isSuccessful()) { Log.w(TAG, "signInWithCredential", task.getException()); Toast.makeText(FacebookLoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); } // ... } }); }
  • 35. Realtime Database • Cloud-hosted NoSQL database • Synchronization & conflict resolution • Access directly from your app
  • 37. Realtime Database // Write a message to the database FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference myRef = database.getReference("message"); myRef.setValue("Hello, World!");
  • 38. Realtime Database // Read from the database myRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { // This method is called once with the initial value and again // whenever data at this location is updated. String value = dataSnapshot.getValue(String.class); Log.d(TAG, "Value is: " + value); } @Override public void onCancelled(DatabaseError error) { // Failed to read value Log.w(TAG, "Failed to read value.", error.toException()); } });
  • 39. Storage • Easy file storage • Handles poor connectivity Backed by & accessible from • Google Cloud Storage
  • 40. Storage FirebaseStorage storage = FirebaseStorage.getInstance();
  • 41. Uploading a file Uri file = Uri.fromFile(new File("path/to/images/rivers.jpg")); StorageReference riversRef = storageRef.child("images/"+file.getLastPathSegment()); uploadTask = riversRef.putFile(file); // Register observers to listen for when the download is done or if it fails uploadTask.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { // Handle unsuccessful uploads } }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { // taskSnapshot.getMetadata() contains file metadata such as size, // content-type, and download URL. Uri downloadUrl = taskSnapshot.getDownloadUrl(); } });
  • 42. Downloading a file islandRef = storageRef.child("images/island.jpg"); File localFile = File.createTempFile("images", "jpg"); islandRef.getFile(localFile) .addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() { @Override public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) { // Local temp file has been created } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { // Handle any errors } });
  • 44. Hosting Install the Firebase CLI npm install –g firebase-tools Initialize your app $ firebase init Add a file Deploy your website $ firebase deploy
  • 45. Hosting Install the Firebase CLI npm install –g firebase-tools Initialize your app $ firebase init Add a file Deploy your website $ firebase deploy
  • 46. Remote Config Dynamically configures • your app on-the-fly • [Live Demo]
  • 47. Remote Config mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); Set default parameter value as a XML file in res/xml Fetch new configurations with fetch() and replace the current one
  • 49. Cloud Messaging • Firebase Cloud Messaging (FCM) • Enable Push Notifications in just few LoCs • Build on top of GCM, switch to FCM ! • See in details in the next session
  • 51. DEVELOP GROW EARN Backend Services Realtime Database Authentication Hosting Storage Cloud Messaging Remote Config App Quality Services Test Lab for Android Crash Reporting Acquisition Dynamic Links Invites AdWords Re-Engagement Notifications App Indexing In-app Ads AdMob Analytics
  • 52. Crash Reporting • See crashes & impact • Version & OS drill-down • Integrated with Analytics
  • 53. Crash Reporting FirebaseCrash.report(new Exception("My first Android non-fatal error")); FirebaseCrash.log("Activity created"); Basically just add dependency compile 'com.google.firebase:firebase-crash:9.0.2'
  • 55. Test Lab Test on the most popular • devices before you ship • Reports & screenshots • Robo & custom tests
  • 60. DEVELOP GROW EARN Backend Services Realtime Database Authentication Hosting Storage Cloud Messaging Remote Config App Quality Services Test Lab for Android Crash Reporting Acquisition Dynamic Links Invites AdWords Re-Engagement Notifications App Indexing In-app Ads AdMob Analytics
  • 61. Dynamic Links Customize different user experiences • via a single URL • Works across platforms Preserves URL state, even through • app install flow • Analytics insights
  • 64. Invites • Drop-in widget for app sharing • Supports SMS and Email • Recipient suggestions from Google • Built on Dynamic Links
  • 66. Invites private void onInviteClicked() { Intent intent = new AppInviteInvitation .IntentBuilder(getString(R.string.invitation_title)) .setMessage(getString(R.string.invitation_message)) .setDeepLink(Uri.parse(getString(R.string.invitation_deep_link))) .setCustomImage(Uri.parse(getString(R.string.invitation_custom_image))) .setCallToActionText(getString(R.string.invitation_cta)) .build(); startActivityForResult(intent, REQUEST_INVITE); }
  • 67. Invites @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.d(TAG, "onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode); if (requestCode == REQUEST_INVITE) { if (resultCode == RESULT_OK) { // Get the invitation IDs of all sent messages String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data); for (String id : ids) { Log.d(TAG, "onActivityResult: sent invitation " + id); } } else { // Sending failed or it was canceled, show failure message to the user // ... } } }
  • 68. App Indexing • Integrate with Google Search • Index app content • Boost search ranking
  • 70. AdMob by Google Engaging formats: • video, interstitial & native • 1M+ apps using AdMob • Integrated with Firebase SDK
  • 71. Analytics • Designed for apps • Event and user centric • Connects across Firebase
  • 83. DEVELOP GROW EARN Backend Services Realtime Database Authentication Hosting Storage Cloud Messaging Remote Config App Quality Services Test Lab for Android Crash Reporting Acquisition Dynamic Links Invites AdWords Re-Engagement Notifications App Indexing In-app Ads AdMob Analytics