Client to client short messaging










1














I am implementing small communication between two clients in Android. Currently I am using Firebase Realtime Database that holding all my users with push tokens.



I use Firebase Cloud Messaging to send push messages from one to other using REST embedded in my code. This is not so good practice due to that I need to save my server key hardcoded in the app. I thought about using XMPP but its bit overkill for what I need.



I need small communication between the users for one asking the other for their location and gets the coordinates in return. The messages do not needed to be saved on server and it just one time request and response. As I previously said I am currently using FCM for that.



Can you suggest maybe better solution for this, without XMPP?










share|improve this question























  • You can use SOCKET IO for that
    – Nikunj Patel
    Nov 13 at 11:09










  • Could you elaborate a little on why using Firebase Cloud Messaging (FCM) isn't suitable? I have an idea that uses the Realtime Database to accomplish this but it does seem that FCM would be the preferred method.
    – Grimthorr
    Nov 16 at 14:11















1














I am implementing small communication between two clients in Android. Currently I am using Firebase Realtime Database that holding all my users with push tokens.



I use Firebase Cloud Messaging to send push messages from one to other using REST embedded in my code. This is not so good practice due to that I need to save my server key hardcoded in the app. I thought about using XMPP but its bit overkill for what I need.



I need small communication between the users for one asking the other for their location and gets the coordinates in return. The messages do not needed to be saved on server and it just one time request and response. As I previously said I am currently using FCM for that.



Can you suggest maybe better solution for this, without XMPP?










share|improve this question























  • You can use SOCKET IO for that
    – Nikunj Patel
    Nov 13 at 11:09










  • Could you elaborate a little on why using Firebase Cloud Messaging (FCM) isn't suitable? I have an idea that uses the Realtime Database to accomplish this but it does seem that FCM would be the preferred method.
    – Grimthorr
    Nov 16 at 14:11













1












1








1


2





I am implementing small communication between two clients in Android. Currently I am using Firebase Realtime Database that holding all my users with push tokens.



I use Firebase Cloud Messaging to send push messages from one to other using REST embedded in my code. This is not so good practice due to that I need to save my server key hardcoded in the app. I thought about using XMPP but its bit overkill for what I need.



I need small communication between the users for one asking the other for their location and gets the coordinates in return. The messages do not needed to be saved on server and it just one time request and response. As I previously said I am currently using FCM for that.



Can you suggest maybe better solution for this, without XMPP?










share|improve this question















I am implementing small communication between two clients in Android. Currently I am using Firebase Realtime Database that holding all my users with push tokens.



I use Firebase Cloud Messaging to send push messages from one to other using REST embedded in my code. This is not so good practice due to that I need to save my server key hardcoded in the app. I thought about using XMPP but its bit overkill for what I need.



I need small communication between the users for one asking the other for their location and gets the coordinates in return. The messages do not needed to be saved on server and it just one time request and response. As I previously said I am currently using FCM for that.



Can you suggest maybe better solution for this, without XMPP?







android firebase firebase-realtime-database firebase-cloud-messaging xmpp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 at 16:45









Grimthorr

4,32442135




4,32442135










asked Nov 5 at 9:41









Dim

1,06965494




1,06965494











  • You can use SOCKET IO for that
    – Nikunj Patel
    Nov 13 at 11:09










  • Could you elaborate a little on why using Firebase Cloud Messaging (FCM) isn't suitable? I have an idea that uses the Realtime Database to accomplish this but it does seem that FCM would be the preferred method.
    – Grimthorr
    Nov 16 at 14:11
















  • You can use SOCKET IO for that
    – Nikunj Patel
    Nov 13 at 11:09










  • Could you elaborate a little on why using Firebase Cloud Messaging (FCM) isn't suitable? I have an idea that uses the Realtime Database to accomplish this but it does seem that FCM would be the preferred method.
    – Grimthorr
    Nov 16 at 14:11















You can use SOCKET IO for that
– Nikunj Patel
Nov 13 at 11:09




You can use SOCKET IO for that
– Nikunj Patel
Nov 13 at 11:09












Could you elaborate a little on why using Firebase Cloud Messaging (FCM) isn't suitable? I have an idea that uses the Realtime Database to accomplish this but it does seem that FCM would be the preferred method.
– Grimthorr
Nov 16 at 14:11




Could you elaborate a little on why using Firebase Cloud Messaging (FCM) isn't suitable? I have an idea that uses the Realtime Database to accomplish this but it does seem that FCM would be the preferred method.
– Grimthorr
Nov 16 at 14:11












3 Answers
3






active

oldest

votes


















1





+50









It seems like using Firebase Cloud Messaging would be the preferable method. However, if that isn't working for you, we could leverage the Realtime Database to do this, although it won't be strictly client-to-client.



As an example: imagine we have 2 users with the UIDs of user1 and user2. The database could be structured so that each user has their own list under the /requests and /responses nodes:




"requests":
"user1": ,
"user2":
,
"responses":
"user1": ,
"user2":




In the scenario where user2 wants to request the location of user1, the clients would follow the below flow:



flow



For Android, this would work something like:



private FirebaseDatabase database = FirebaseDatabase.getInstance();
private FirebaseAuth auth = FirebaseAuth.getInstance();
private String myUserId;

private void setup()
if (auth.getCurrentUser() == null) // User must be signed-in
finish();
return;


myUserId = auth.getCurrentUser().getUid();

DatabaseReference requestsRef = database.getReference("requests").child(myUserId);
DatabaseReference responsesRef = database.getReference("responses").child(myUserId);

requestsRef.addChildEventListener(new ChildEventListener()
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s)
handleRequest(dataSnapshot.getKey());
dataSnapshot.getRef().removeValue(); // Delete the request once it's been handled

// ...
);

responsesRef.addChildEventListener(new ChildEventListener()
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s)
String from = dataSnapshot.getKey();
String coordinates = dataSnapshot.getValue(String.class);
if (from != null && coordinates != null) handleResponse(from, coordinates);
dataSnapshot.getRef().removeValue(); // Delete the response once it's been handled

// ...
);


private void handleResponse(String from, String coordinates)
Toast.makeText(this, String.format("User: %s is located at: %s", from, coordinates), Toast.LENGTH_SHORT).show();


private void handleRequest(String from)
Toast.makeText(this, String.format("User: %s wants to know our location", from), Toast.LENGTH_SHORT).show();
sendResponse(from);


private void sendResponse(String to)
String myCoordinates = "37.4220° N, 122.0841° W"; // Example, this will need implementing
database.getReference("/responses").child(to).child(myUserId).setValue(myCoordinates);


private void sendRequest(String to)
database.getReference("/requests").child(to).child(myUserId).setValue(true);



With this example, both user's clients will first call setup() to begin listening for requests and responses.



Then, to request a user's coordinates, call sendRequest() from one client. The other client will receive this request in the handleRequest() method and send their coordinates to the database. Finally, the requesting client will receive this response in the handleResponse() method.



This probably isn't quite what you're looking for, but it was a fun exercise for me, so I wanted to share it anyway.






share|improve this answer




























    1














    SOCKET is very simple and a lot of big corporations are using it.



    With Socket client you can enable Send and Receive method if the commutations will be 2 ways inside your application.



    For Example:
    To send your Lat & Long use



    String location = "123123,123123"
    mSocket.emit("Update", location);


    And to receive other user new location place below code inside your OnCreate:



    mSocket.on("Update", GettingUpdate);
    mSocket.connect();


    And Do your logic inside GettingUpdate Method



    private Emitter.Listener GettingUpdate= new Emitter.Listener() 
    @Override
    public void call(final Object.. args)
    getActivity().runOnUiThread(new Runnable()
    @Override
    public void run()
    JSONObject data = (JSONObject) args[0];
    String location;
    try
    location= data.getString("location");
    catch (JSONException e)
    return;


    Toast.makeText(getActivity(), message,Toast.LENGTH_LONG).show();


    );

    ;


    you can find example at documentation



    Android project example : Github






    share|improve this answer




























      1














      now you can use firebase realtime database and cloud firestore database no need to FCM you will get realtime and offline as well



      https://code.tutsplus.com/tutorials/how-to-create-an-android-chat-app-using-firebase--cms-27397



      enjoy






      share|improve this answer




















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53151784%2fclient-to-client-short-messaging%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1





        +50









        It seems like using Firebase Cloud Messaging would be the preferable method. However, if that isn't working for you, we could leverage the Realtime Database to do this, although it won't be strictly client-to-client.



        As an example: imagine we have 2 users with the UIDs of user1 and user2. The database could be structured so that each user has their own list under the /requests and /responses nodes:




        "requests":
        "user1": ,
        "user2":
        ,
        "responses":
        "user1": ,
        "user2":




        In the scenario where user2 wants to request the location of user1, the clients would follow the below flow:



        flow



        For Android, this would work something like:



        private FirebaseDatabase database = FirebaseDatabase.getInstance();
        private FirebaseAuth auth = FirebaseAuth.getInstance();
        private String myUserId;

        private void setup()
        if (auth.getCurrentUser() == null) // User must be signed-in
        finish();
        return;


        myUserId = auth.getCurrentUser().getUid();

        DatabaseReference requestsRef = database.getReference("requests").child(myUserId);
        DatabaseReference responsesRef = database.getReference("responses").child(myUserId);

        requestsRef.addChildEventListener(new ChildEventListener()
        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s)
        handleRequest(dataSnapshot.getKey());
        dataSnapshot.getRef().removeValue(); // Delete the request once it's been handled

        // ...
        );

        responsesRef.addChildEventListener(new ChildEventListener()
        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s)
        String from = dataSnapshot.getKey();
        String coordinates = dataSnapshot.getValue(String.class);
        if (from != null && coordinates != null) handleResponse(from, coordinates);
        dataSnapshot.getRef().removeValue(); // Delete the response once it's been handled

        // ...
        );


        private void handleResponse(String from, String coordinates)
        Toast.makeText(this, String.format("User: %s is located at: %s", from, coordinates), Toast.LENGTH_SHORT).show();


        private void handleRequest(String from)
        Toast.makeText(this, String.format("User: %s wants to know our location", from), Toast.LENGTH_SHORT).show();
        sendResponse(from);


        private void sendResponse(String to)
        String myCoordinates = "37.4220° N, 122.0841° W"; // Example, this will need implementing
        database.getReference("/responses").child(to).child(myUserId).setValue(myCoordinates);


        private void sendRequest(String to)
        database.getReference("/requests").child(to).child(myUserId).setValue(true);



        With this example, both user's clients will first call setup() to begin listening for requests and responses.



        Then, to request a user's coordinates, call sendRequest() from one client. The other client will receive this request in the handleRequest() method and send their coordinates to the database. Finally, the requesting client will receive this response in the handleResponse() method.



        This probably isn't quite what you're looking for, but it was a fun exercise for me, so I wanted to share it anyway.






        share|improve this answer

























          1





          +50









          It seems like using Firebase Cloud Messaging would be the preferable method. However, if that isn't working for you, we could leverage the Realtime Database to do this, although it won't be strictly client-to-client.



          As an example: imagine we have 2 users with the UIDs of user1 and user2. The database could be structured so that each user has their own list under the /requests and /responses nodes:




          "requests":
          "user1": ,
          "user2":
          ,
          "responses":
          "user1": ,
          "user2":




          In the scenario where user2 wants to request the location of user1, the clients would follow the below flow:



          flow



          For Android, this would work something like:



          private FirebaseDatabase database = FirebaseDatabase.getInstance();
          private FirebaseAuth auth = FirebaseAuth.getInstance();
          private String myUserId;

          private void setup()
          if (auth.getCurrentUser() == null) // User must be signed-in
          finish();
          return;


          myUserId = auth.getCurrentUser().getUid();

          DatabaseReference requestsRef = database.getReference("requests").child(myUserId);
          DatabaseReference responsesRef = database.getReference("responses").child(myUserId);

          requestsRef.addChildEventListener(new ChildEventListener()
          @Override
          public void onChildAdded(DataSnapshot dataSnapshot, String s)
          handleRequest(dataSnapshot.getKey());
          dataSnapshot.getRef().removeValue(); // Delete the request once it's been handled

          // ...
          );

          responsesRef.addChildEventListener(new ChildEventListener()
          @Override
          public void onChildAdded(DataSnapshot dataSnapshot, String s)
          String from = dataSnapshot.getKey();
          String coordinates = dataSnapshot.getValue(String.class);
          if (from != null && coordinates != null) handleResponse(from, coordinates);
          dataSnapshot.getRef().removeValue(); // Delete the response once it's been handled

          // ...
          );


          private void handleResponse(String from, String coordinates)
          Toast.makeText(this, String.format("User: %s is located at: %s", from, coordinates), Toast.LENGTH_SHORT).show();


          private void handleRequest(String from)
          Toast.makeText(this, String.format("User: %s wants to know our location", from), Toast.LENGTH_SHORT).show();
          sendResponse(from);


          private void sendResponse(String to)
          String myCoordinates = "37.4220° N, 122.0841° W"; // Example, this will need implementing
          database.getReference("/responses").child(to).child(myUserId).setValue(myCoordinates);


          private void sendRequest(String to)
          database.getReference("/requests").child(to).child(myUserId).setValue(true);



          With this example, both user's clients will first call setup() to begin listening for requests and responses.



          Then, to request a user's coordinates, call sendRequest() from one client. The other client will receive this request in the handleRequest() method and send their coordinates to the database. Finally, the requesting client will receive this response in the handleResponse() method.



          This probably isn't quite what you're looking for, but it was a fun exercise for me, so I wanted to share it anyway.






          share|improve this answer























            1





            +50







            1





            +50



            1




            +50




            It seems like using Firebase Cloud Messaging would be the preferable method. However, if that isn't working for you, we could leverage the Realtime Database to do this, although it won't be strictly client-to-client.



            As an example: imagine we have 2 users with the UIDs of user1 and user2. The database could be structured so that each user has their own list under the /requests and /responses nodes:




            "requests":
            "user1": ,
            "user2":
            ,
            "responses":
            "user1": ,
            "user2":




            In the scenario where user2 wants to request the location of user1, the clients would follow the below flow:



            flow



            For Android, this would work something like:



            private FirebaseDatabase database = FirebaseDatabase.getInstance();
            private FirebaseAuth auth = FirebaseAuth.getInstance();
            private String myUserId;

            private void setup()
            if (auth.getCurrentUser() == null) // User must be signed-in
            finish();
            return;


            myUserId = auth.getCurrentUser().getUid();

            DatabaseReference requestsRef = database.getReference("requests").child(myUserId);
            DatabaseReference responsesRef = database.getReference("responses").child(myUserId);

            requestsRef.addChildEventListener(new ChildEventListener()
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s)
            handleRequest(dataSnapshot.getKey());
            dataSnapshot.getRef().removeValue(); // Delete the request once it's been handled

            // ...
            );

            responsesRef.addChildEventListener(new ChildEventListener()
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s)
            String from = dataSnapshot.getKey();
            String coordinates = dataSnapshot.getValue(String.class);
            if (from != null && coordinates != null) handleResponse(from, coordinates);
            dataSnapshot.getRef().removeValue(); // Delete the response once it's been handled

            // ...
            );


            private void handleResponse(String from, String coordinates)
            Toast.makeText(this, String.format("User: %s is located at: %s", from, coordinates), Toast.LENGTH_SHORT).show();


            private void handleRequest(String from)
            Toast.makeText(this, String.format("User: %s wants to know our location", from), Toast.LENGTH_SHORT).show();
            sendResponse(from);


            private void sendResponse(String to)
            String myCoordinates = "37.4220° N, 122.0841° W"; // Example, this will need implementing
            database.getReference("/responses").child(to).child(myUserId).setValue(myCoordinates);


            private void sendRequest(String to)
            database.getReference("/requests").child(to).child(myUserId).setValue(true);



            With this example, both user's clients will first call setup() to begin listening for requests and responses.



            Then, to request a user's coordinates, call sendRequest() from one client. The other client will receive this request in the handleRequest() method and send their coordinates to the database. Finally, the requesting client will receive this response in the handleResponse() method.



            This probably isn't quite what you're looking for, but it was a fun exercise for me, so I wanted to share it anyway.






            share|improve this answer












            It seems like using Firebase Cloud Messaging would be the preferable method. However, if that isn't working for you, we could leverage the Realtime Database to do this, although it won't be strictly client-to-client.



            As an example: imagine we have 2 users with the UIDs of user1 and user2. The database could be structured so that each user has their own list under the /requests and /responses nodes:




            "requests":
            "user1": ,
            "user2":
            ,
            "responses":
            "user1": ,
            "user2":




            In the scenario where user2 wants to request the location of user1, the clients would follow the below flow:



            flow



            For Android, this would work something like:



            private FirebaseDatabase database = FirebaseDatabase.getInstance();
            private FirebaseAuth auth = FirebaseAuth.getInstance();
            private String myUserId;

            private void setup()
            if (auth.getCurrentUser() == null) // User must be signed-in
            finish();
            return;


            myUserId = auth.getCurrentUser().getUid();

            DatabaseReference requestsRef = database.getReference("requests").child(myUserId);
            DatabaseReference responsesRef = database.getReference("responses").child(myUserId);

            requestsRef.addChildEventListener(new ChildEventListener()
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s)
            handleRequest(dataSnapshot.getKey());
            dataSnapshot.getRef().removeValue(); // Delete the request once it's been handled

            // ...
            );

            responsesRef.addChildEventListener(new ChildEventListener()
            @Override
            public void onChildAdded(DataSnapshot dataSnapshot, String s)
            String from = dataSnapshot.getKey();
            String coordinates = dataSnapshot.getValue(String.class);
            if (from != null && coordinates != null) handleResponse(from, coordinates);
            dataSnapshot.getRef().removeValue(); // Delete the response once it's been handled

            // ...
            );


            private void handleResponse(String from, String coordinates)
            Toast.makeText(this, String.format("User: %s is located at: %s", from, coordinates), Toast.LENGTH_SHORT).show();


            private void handleRequest(String from)
            Toast.makeText(this, String.format("User: %s wants to know our location", from), Toast.LENGTH_SHORT).show();
            sendResponse(from);


            private void sendResponse(String to)
            String myCoordinates = "37.4220° N, 122.0841° W"; // Example, this will need implementing
            database.getReference("/responses").child(to).child(myUserId).setValue(myCoordinates);


            private void sendRequest(String to)
            database.getReference("/requests").child(to).child(myUserId).setValue(true);



            With this example, both user's clients will first call setup() to begin listening for requests and responses.



            Then, to request a user's coordinates, call sendRequest() from one client. The other client will receive this request in the handleRequest() method and send their coordinates to the database. Finally, the requesting client will receive this response in the handleResponse() method.



            This probably isn't quite what you're looking for, but it was a fun exercise for me, so I wanted to share it anyway.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 16 at 14:59









            Grimthorr

            4,32442135




            4,32442135























                1














                SOCKET is very simple and a lot of big corporations are using it.



                With Socket client you can enable Send and Receive method if the commutations will be 2 ways inside your application.



                For Example:
                To send your Lat & Long use



                String location = "123123,123123"
                mSocket.emit("Update", location);


                And to receive other user new location place below code inside your OnCreate:



                mSocket.on("Update", GettingUpdate);
                mSocket.connect();


                And Do your logic inside GettingUpdate Method



                private Emitter.Listener GettingUpdate= new Emitter.Listener() 
                @Override
                public void call(final Object.. args)
                getActivity().runOnUiThread(new Runnable()
                @Override
                public void run()
                JSONObject data = (JSONObject) args[0];
                String location;
                try
                location= data.getString("location");
                catch (JSONException e)
                return;


                Toast.makeText(getActivity(), message,Toast.LENGTH_LONG).show();


                );

                ;


                you can find example at documentation



                Android project example : Github






                share|improve this answer

























                  1














                  SOCKET is very simple and a lot of big corporations are using it.



                  With Socket client you can enable Send and Receive method if the commutations will be 2 ways inside your application.



                  For Example:
                  To send your Lat & Long use



                  String location = "123123,123123"
                  mSocket.emit("Update", location);


                  And to receive other user new location place below code inside your OnCreate:



                  mSocket.on("Update", GettingUpdate);
                  mSocket.connect();


                  And Do your logic inside GettingUpdate Method



                  private Emitter.Listener GettingUpdate= new Emitter.Listener() 
                  @Override
                  public void call(final Object.. args)
                  getActivity().runOnUiThread(new Runnable()
                  @Override
                  public void run()
                  JSONObject data = (JSONObject) args[0];
                  String location;
                  try
                  location= data.getString("location");
                  catch (JSONException e)
                  return;


                  Toast.makeText(getActivity(), message,Toast.LENGTH_LONG).show();


                  );

                  ;


                  you can find example at documentation



                  Android project example : Github






                  share|improve this answer























                    1












                    1








                    1






                    SOCKET is very simple and a lot of big corporations are using it.



                    With Socket client you can enable Send and Receive method if the commutations will be 2 ways inside your application.



                    For Example:
                    To send your Lat & Long use



                    String location = "123123,123123"
                    mSocket.emit("Update", location);


                    And to receive other user new location place below code inside your OnCreate:



                    mSocket.on("Update", GettingUpdate);
                    mSocket.connect();


                    And Do your logic inside GettingUpdate Method



                    private Emitter.Listener GettingUpdate= new Emitter.Listener() 
                    @Override
                    public void call(final Object.. args)
                    getActivity().runOnUiThread(new Runnable()
                    @Override
                    public void run()
                    JSONObject data = (JSONObject) args[0];
                    String location;
                    try
                    location= data.getString("location");
                    catch (JSONException e)
                    return;


                    Toast.makeText(getActivity(), message,Toast.LENGTH_LONG).show();


                    );

                    ;


                    you can find example at documentation



                    Android project example : Github






                    share|improve this answer












                    SOCKET is very simple and a lot of big corporations are using it.



                    With Socket client you can enable Send and Receive method if the commutations will be 2 ways inside your application.



                    For Example:
                    To send your Lat & Long use



                    String location = "123123,123123"
                    mSocket.emit("Update", location);


                    And to receive other user new location place below code inside your OnCreate:



                    mSocket.on("Update", GettingUpdate);
                    mSocket.connect();


                    And Do your logic inside GettingUpdate Method



                    private Emitter.Listener GettingUpdate= new Emitter.Listener() 
                    @Override
                    public void call(final Object.. args)
                    getActivity().runOnUiThread(new Runnable()
                    @Override
                    public void run()
                    JSONObject data = (JSONObject) args[0];
                    String location;
                    try
                    location= data.getString("location");
                    catch (JSONException e)
                    return;


                    Toast.makeText(getActivity(), message,Toast.LENGTH_LONG).show();


                    );

                    ;


                    you can find example at documentation



                    Android project example : Github







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 13 at 12:34









                    hossam scott

                    1




                    1





















                        1














                        now you can use firebase realtime database and cloud firestore database no need to FCM you will get realtime and offline as well



                        https://code.tutsplus.com/tutorials/how-to-create-an-android-chat-app-using-firebase--cms-27397



                        enjoy






                        share|improve this answer

























                          1














                          now you can use firebase realtime database and cloud firestore database no need to FCM you will get realtime and offline as well



                          https://code.tutsplus.com/tutorials/how-to-create-an-android-chat-app-using-firebase--cms-27397



                          enjoy






                          share|improve this answer























                            1












                            1








                            1






                            now you can use firebase realtime database and cloud firestore database no need to FCM you will get realtime and offline as well



                            https://code.tutsplus.com/tutorials/how-to-create-an-android-chat-app-using-firebase--cms-27397



                            enjoy






                            share|improve this answer












                            now you can use firebase realtime database and cloud firestore database no need to FCM you will get realtime and offline as well



                            https://code.tutsplus.com/tutorials/how-to-create-an-android-chat-app-using-firebase--cms-27397



                            enjoy







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 15 at 11:36









                            Ashish Chaugule

                            1,17968




                            1,17968



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53151784%2fclient-to-client-short-messaging%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                                Syphilis

                                Darth Vader #20