Firebase
- 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.
- 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.
- 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.
- 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.
- 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();
}
// ...
}
});
}
- 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());
}
});
- 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
- 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
- 55. Test Lab
Test on the most popular
•
devices before you ship
•
Reports & screenshots
•
Robo & custom tests
- 61. Dynamic Links
Customize different user experiences
•
via a single URL
•
Works across platforms
Preserves URL state, even through
•
app install flow
•
Analytics insights
- 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
// ...
}
}
}
- 70. AdMob by Google
Engaging formats:
•
video, interstitial & native
•
1M+ apps using AdMob
•
Integrated with Firebase SDK