Drift is a messaging tool that allows businesses to communicate with website visitors and consumers in real-time and from any location.
The Firebase Realtime Database lets you build rich, collaborative applications by allowing secure access to the database directly from client-side code.
Firebase Realtime Database IntegrationsDrift + Firebase Realtime Database
Create or Replace Firebase Realtime Database Record to Realtime Database from New Message in Drift Read More...Firebase Realtime Database + Drift
Create or Update Contact From External to Drift from New Child Object in a Firebase Realtime Database in Realtime Database Read More...Firebase Realtime Database + Drift
Update Known Contact in Drift when New Child Object in a Firebase Realtime Database is created in Realtime Database Read More...Firebase Realtime Database + Drift
Create or Update Contact From External from Drift from Edit or Updated Child Object in Firebase Realtime Database to Realtime Database Read More...Firebase Realtime Database + Drift
Update Known Contact in Drift when Edit or Updated Child Object in Firebase Realtime Database is added to Realtime Database Read More...It's easy to connect Drift + Firebase Realtime Database without coding knowledge. Start creating your own business flow.
Triggers each time when a new message in a conversation is received.
Triggers on updation of a child object in firebase realtime database.
New Child Object in a Firebase Realtime Database
Create or update a contact.
Updates an existing contact.
Creates or replaces a child object within your Firebase Realtime Database.
(30 seconds)
(10 seconds)
(30 seconds)
(10 seconds)
(2 minutes)
The topic of my article is the integration of Drift and Firebase Realtime Database. Drift is an app that allows users to chat with their friends online and help them find restaurants, events, and more. Firebase is a mobile database which enables real-time data synchronization for chat apps. By integrating both of these tops together, it will be possible to share location details with friends when posting a message on Drift. This article will go through how to integrate the two tops, and some benefits of doing so.
To start off this article, I will explain how to integrate Drift and Firebase Realtime Database. First, one has to set up a new project in Android Studio 3 using the Blank Activity option. Then one must add the dependencies needed to run the application. The fplowing is a snippet from the build.gradle file.
dependencies { implementation 'com.google.firebase:firebase-core:16.0.2' }
Next, one must create a new class called “FireBaseHelper” that extends FireBaseMessagingService and implements MessageApi.ConfigureListener interface.
class FireBaseHelper extends FireBaseMessagingService implements MessageApi . ConfigureListener { private static final String TAG = "FireBaseHelper" ; @Override public void onMessageReceived ( RemoteMessage remoteMessage . { // TODO. Handle FCM messages here. Log . d ( TAG , "onMessageReceived" ); } @Override public void onMessageError ( RemoteMessage remoteMessage , Throwable t . { // TODO. Handle errors here. Log . d ( TAG , "onMessageError" ); } @Override public void onMessageSent ( RemoteMessage remoteMessage . { Log . d ( TAG , "onMessageSent" ); } }
The next step is to add the fplowing code to the MainActivity code of my app.
private FireBaseHelper mFireBaseHelper ; @Override protected void onCreate ( Bundle savedInstanceState . { Log . d ( TAG , "onCreate" ); super . onCreate ( savedInstanceState ); setContentView ( R . layout . activity_main ); mFireBaseHelper = FireBaseHelper . getInstance (); mFireBaseHelper . setDebugLoggingEnabled ( true ); mFireBaseHelper . register (); if ( mFireBaseHelper . isMessagingActive (). { Intent intent = new Intent ( this , MainActivity . class ); startActivity ( intent ); finish (); } else { Log . d ( TAG , "No Firebase Instance found." ); } } @Override protected void onStart (. { super . onStart (); Log . d ( TAG , "onStart" ); mFireBaseHelper . onStart (); mFireBaseHelper . register (); if (! mFireBaseHelper . isMessagingActive (). { return ; } Intent intent = new Intent ( this , MainActivity . class ); startActivity ( intent ); finish (); } @Override protected void onStop (. { super . onStop (); Log . d ( TAG , "onStop" ); mFireBaseHelper . onStop (); if (! mFireBaseHelper . isMessagingActive (). { return ; } Intent intent = new Intent ( this , MainActivity . class ); startActivity ( intent ); finish (); }
The next step is to add code that will check for incoming messages from Firebase, in the “onCreate()” method of the MainActivity class.
mFireBaseHelper = FireBaseHelper . getInstance (); mFireBaseHelper . setDebugLoggingEnabled ( true ); mFireBaseHelper . register (); if ( mFireBaseHelper . isMessagingActive (). { Intent intent = new Intent ( this , MainActivity . class ); startActivity ( intent ); finish (); } else { Log . d ( TAG , "No Firebase Instance found." ); }
In order to send messages to Firebase, use the fplowing sample code in your “MainActivity” class:
Intent intent = new Intent ( this , MainActivity . class ); mFireBaseHelper . sendMessage ( this , "Hello from Drift!" , null , null , 0 /* also checks if device is online or offline / , "[email protected]" / also checks if device already exists in database / , null / also checks if conversation already exists in database */ );
Lastly, one must add code to the “onDestroy()” method of the MainActivity class to clean up any data stored in Firebase by destroying the conversation. This can be done by calling the fplowing:
mFireBaseHelper . deleteConversationByToken ( "[email protected]" );
By using Drift and Firebase Realtime Database together, it is possible to enhance a typical “chat” application by adding features such as sharing locations within chats. This allows users to see where their friends are located at all times, making it much easier for them to meet up during parties and events. Also, since Drift already has a large user base, it would be beneficial for developers who have not yet integrated their applications with Firebase to do so anyway because more users are likely to come after its integration with Drift.
The process to integrate Drift and Firebase Realtime Database may seem complicated and intimidating. This is why Appy Pie Connect has come up with a simple, affordable, and quick spution to help you automate your workflows. Click on the button below to begin.