For more information, visit firebase.google.com.
https://github.com/firebase/friendlychat
- Go to the Firebase console.
- Create a New Project.
- Connect your Android App.
- Add google-services.json file to your app.
- Add google-services plugin to your app.
- Sync your project with gradle files.
** Enable Authentication - Firebase console**
- Enable Google as a sign-in provider from the
Firebase console > Authentication. - Set rules on the database from the
Firebase console > Database > Ruleslike:
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
** Import Messages **
- Go to the
Firebase console > Database. - Select
Import JSONfrom the overflow menu of the Database. - Import the
initial_messages.jsonfile.
** Test message sync **
- From the
Firebase console > Database > DATAtab, select the+sign on themessageselement. - Give the new element a name of -ABCD (note the '
-' sign). - Select the
+sign on the -ABCD element. - Give the new element a name of
nameand value ofyour name. - Select the
+sign on the -ABCD element. - Give the new element a name of
textand value ofHello, World!. - Select Add.
** Test On-device App Indexing **
- Start up the
FriendlyChat appand send a new message with the text Hi world! - Go to the
Google app, switch to In Apps and search for Hi world. - Confirm that the message can be found in the Google app.
- Tap on the result and confirm the FriendlyChat app opens.
** Test Background Notifications **
Runthe updated application.- Hit the device's home button (or otherwise send the app to the
background). - In
Firebase consoleselectNotificationsfrom the left navigation bar. - Set
MessageText to "Friendly Chat?". - Select the app we connected earlier as the
App target. - Click
Send Message - Confirm that message is received and notification is displayed on the device. The user should receive a notification that takes them back to the application when tapped.
** Test Remote Config **
- Go to
Firebase console > Remote Config. - Click on
Add Parameter. - Set the
Parameter keytofriendly_msg_lengthand theParameter valueto20. - Click
Publish Changeswhen you're done.
** Test App Invite **
Runthe application.- Tap the
menu overflowat the top right of the screen. - Select the
Inviteoption. - You should see the
App Invites interfacewhich will allow you to select Email and SMS contacts and send a custom invitation. You must have control of the receiving account to view the invitation once sent. - Tap
sendand verify that the invitation is sent to the selected contact. - Verify that selected contact is taken to app install screen from invite.
** Test Firebase Crash **
Runthe application.- Verify that the
Cause Crashmenu item is available from theoverflow menu. - Verify that when
Cause Crashis selected the application crashes. - From the logcat verify that the crash report was successfully uploaded. If you do not see logs indicating that the crash report was sent, make sure that the Android Studio logcat filter is set to No Filters.
Check more in codelabs.developers.google.com.