Wednesday, July 6

Android App : Friendly Chat

https://codelabs.developers.google.com/codelabs/firebase-android/#0

1. Got the starting code from github repository.
** Opened the android-start project in Android Studio, File -> Open -> FriendlyChat -> android-start.

2. Created Firebase console Project.

3. Connected Firebase and Android App.

4. Enabled Authentication. (added code for authentication.)

5. Activated Firebase Realtime Database
Imported initial_messages.json (from 'FriendlyChat' folder in laptop) in Firebase Database.

Added a Database instance variable in the MainActivity class:
private DatabaseReference mFirebaseDatabaseReference;

mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference();

6. Implemented message sending.
Listened for click events on the send button, created a new FriendlyMessage object with the contents of the message field, and pushed the message to the database. 
The push() method adds an automatically generated ID to the pushed object's path.

7. Used Firebase Cloud Messaging (FCM) to send notifications to the users of our app. 
Added FCM dependency. 
Added FCM Services. 
Added corresponding service tags in AndroidManifest.xml.
a. MyFirebaseMessagingService
b. MyFirebaseInstanceIdService

8. Remotely configured Friendly Message Length.
(Firebase Remote Config is a cloud service that lets you change the behaviour and appearance of your app without requiring users to download an app update. https://firebase.google.com/docs/remote-config/)

a. Added Config Rules in Firebase console

b. Added Firebase Remote Config dependency
compile 'com.google.firebase:firebase-config:9.0.0'

c. Added a Firebase Remote Config instance variable in the MainActivity class:

private FirebaseRemoteConfig mFirebaseRemoteConfig;

// Initialize Firebase Remote Config.
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
Methods used:
1. setConfigSettings()
2. setDefaults()
3. getInfo()
4. fetch()
5. activateFetched()
6. getLong()

9. Sent Install Invites.
(Firebase App Invites provide a simple way for your users to share your application with their friends through Email or SMS.)

Added AppInvite Dependency
compile 'com.google.android.gms:play-services-appinvite:9.0.0'

Made MainActivity implement the GoogleApiClient.OnConnectionFailedListener interface. Implemented the required onConnectionFailed method.

Added a GoogleApiClient instance variable to MainActivity.
private GoogleApiClient mGoogleApiClient;

Initialized mGoogleApiClient in the onCreate method in the MainActivity.

Sent invitations. Added the sendInvitation method to MainActivity such that it creates and starts the intent which provides the user the ability to send invitations.

Handled the Activity result invite callback, which will indicate whether or not the sending of the invites occurred successfully or not.

Added a call to sendInvitation to the onOptionsItemSelected method in MainActivity.

10. Tracked user flows.
(Firebase Analytics provides a way for you to understand the way users move through your application, where they succeed and where they get stuck. It can also be used to understand the most used parts of your application.)

11. Monetized with Ads.
(AdMob gives you a way to easily monetize your application, you simply add the AdView placeholder and Google handles the ad delivery for you.)

12. Reported crashes.
(Firebase Crash allows your application to report when crashes occur and log the events leading up to the crash.)

No comments:

Post a Comment