I have a product listing that when clicked asks the viewer(user viewing the product) if they would like more information.
If yes then it takes them to a chat interface which the viewer can then send a message to the product author (user who the post belongs to).
The app takes these two users id's and hashes it and combines them to make a single string that is used as the document id for the chat interaction, that way both users read & write from one collection.
Now there is a messages tab in the app and there I would like to get all the chats(interaction between userA and userB) where each of the two users are apart of. So that later on they can go to the messages screen and continue messaging. Is there a way to achieve this?
Related
I would like to share data between two users in my app. Generally, users are registered in the app and the storage of their data is done via Firestore. To access the data I use the UID of the user on the one hand and an id for the corresponding document inside a collection to be accessed on the other.
I am now looking for a way to share some selected data of a user with other users. The data is to be shared via WhatsApp, Email, etc., for example. These are the ways I have thought of so far:
The DataClass with all the stored data is packaged as an app-specific file and sent between the users.
or
The UID of the user and the id of the corresponding document inside the collection are sent. Using these two pieces of information, I can access the data from the user who is to receive the data via Firestore and save it on his or her device.
In general, my data sets are not particularly large. Now to my question:
Which of the two ways seems to make more sense and, above all, how can I implement this or which other sites could help me?
I've tried a few things with FileProvider so far, but haven't really got anywhere. It would be important that the user in question receives a message via e.g. WhatsApp, email, etc., can open my app via this, and the processing of the data for the user begins. Basically, I need to start an intent from the message the user receives with some extra data. How can I achieve that?
If you need any further information, please just let me know. Many thanks in advance!
You might want to have a look at Firebase Dynamic Links, which:
If a user opens a Dynamic Link on iOS or Android, they can be taken directly to the linked content in your native app.
So I am creating an Android application in which suppose there are 2 user types, userType1 & userType2. Now what I want is that only userType1 will see and be able to access the post button, and userType2 Can't see and or access it. So what is the best practice for that?
The best practice would be to implement Firebase Authentication and save user data, either in Cloud Firestore or in the Realtime Database together with the user type. When you start the app, first you have to read the user type and then display the UI elements according to it. I have answered a question in which I have explained how to redirect the user according to its type to the corresponding activity. Here is how you can do that using Cloud Firestore:
How to redirect a user to a specific activity in Cloud Firestore?
Or using the Firebase Realtime Database:
How to redirect multiple types of users to their respective Activities?
The same mechanism can be used to hide/display a button. Don't also forget to secure your data using security rules.
I want to build a notification system in my Android app where I can send a notification to someone upon an event. For example, my app is about a social system where it uses Firestore database (Firebase) to save its users (which means I have a 'users' collection in there), and I have an 'Add as Friend' feature.
Everything works just fine, but I would like to add a feature where when user1 adds user2 as a friend, I would like to send user2 a notification about that.
I have searched in google and saw this post: https://www.geeksforgeeks.org/how-to-push-notification-in-android-using-firebase-cloud-messaging/
Now, from what I understand, this wouldn't help me much cause it only sends the notification from FCM by me (and not to a specific user).
The problem is, I don't really know what to search for (or what to type in google) in order to find what I'm looking for.
Some ideas I thought:
to make a collection in firestore called 'Notifications' where it holds usernames as documentIDs
when user1 sends a friend request to user2, I would add data (like title/message) to 'Notifications/user2/'
But I'm kind of stuck here, I would like to know ideas or if you guys have threads on how do I implement this, I really don't know what should I look for.
Thank you very much and sorry for the long post.
Firebase creates a userID for every user and a usertoken which is a temporary identifier for the device which is connected to this userID. You need to save the usertoken when there is a new one being created in a database(firestore) along with the user with whom you identify this person.
When someone adds this person as a friend you can add a notification in the database that there is a request from person1 to person2.
This change in the database can trigger a cloud function that reacts to changes in the database.
The triggered cloud function sends an FCM to the person which is being added as a friend. This FCM can either be a pure notification or you send data and let your app handle how this data is being handled(saved in a local database or displayed as a custom notification).
Keywords are: FCM, Notification, Firestore, cloud functions, and firebase token
Edit (Answer to 1. comment): Firebase userID and usertoken are created on the device. In the tutorial you implement FCM(I didn't read it complete) and a class called FirebaseMessagingService, from which you can inherit. This class is called, when a message is sent to the device and contains a method called onNewToken. This message is called, when the Firebase Server creates a token for your device and sends it to the device. In this method you might want to send the new token to your database and save it as an identifier for the user of this device. The Tokens are used by firebase to identify devices, to which messages are being sent(You can read about FCM in detail)
Cloud functions are something you can deploy along your firebase project, which get triggered when an event occurs. For example a http call, or a specific change in your database. Cloud functions are written in JS and need to be deployed for your firebase project. (Cloud functions are not for free and you need to pay for each call, but you have some thousand uses for free each month.)
You send a FCM to a specific person by creating a firebase message which is directed to a specific token, tokens or user groups. To identify the person to which you want to send a message you need to have the token for this user, that is why you are saving the tokens from the 1. part in your database and always update the token, when the token changes on the device.
Keep in mind, that a user might use multiple devices. You should have an identifier for you, such as username and along this username you save multiple firebaseIds and Firebase tokens. A single FCM can be directed to up to 100 tokens.
For this question, I am not looking for specific answers, or code or anything, but moreso suggestions on what techniques to employ to accomplish my goal.
I am very new to Android development. I have a bit of a background in Java.
The App I'm looking to build would have two types of users. The Narrator and the Participant.
The Participants would fill out a few fields, and click a button. This data would be integer and string values. Nothing terribly complex. The participants don't really need any sort of feedback beyond success or failure.
The Narrator's app would receive this information, and build a list displaying the information the Participants sent. Possibly the Narrator is able to send a message to the Participant devices prompting them to fill out and send their inputs, but not necessary.
What I am looking for is direction on which sorts of methods or techniques to accomplish this. It could be accomplished over Bluetooth, but even accomplishing it over the internet is arguably better.
It would need to be able to generate a unique session that users can locate and "connect to", as well.
If there are other questions that have info that would help me, feel free to link them. I assume there are. The rub is that I wasn't exactly sure how to ask this question with enough brevity to yield useful search results.
Thanks very much.
Look at realtime cloud db solutions to create the realtime, connect to session that you want to create.
In your app create a registration activity where the user can register as a participant or narrator. Store the user details on the cloud once register with a usertype key under your user model/map.
For example to define a value to usertype use like this.
usertype = 0 for participant
usertype = 1 for narrator
For your main activity you can create 2 layouts:
Layout1 (participant)
Layout2(narrator)
When user login you read the usertype value and assign layout in the oncreate method.
Example
if(usertype==0){
setContentView(Layout1)}
Within the layouts you will add your edittexts, views and buttons as per required for narrators and participants.
You will also write your functions for narrator in its own class/void and the same for participant.
Then use the usertype value to access the defined classes/voids.
You can have a look at firebase as a realtime database or there are plenty other options.
Happy coding.
So according to your explanation, participants will send something to other users which are Narrator. So something like chat system. In that case, you can use Firebase Realtime database. First, see how Firebase real-time database works. You can check this to get an idea.
So when participants fill up something it must receive by the narrator. When participants submit something you just need to send a push notification to all participants. So when participants click on the notifications you will redirect him to a specific activity and can load the participant's submitted form in that.
I am new in android. I am developing android app and using http://parse.com API. I want to implement two types of user Student and Company. Basic signup form has the same fields. Later, I want to add additional information related to the user and specific for each type. Now, problem how to save user information for different type of users?
Make a column of userType in parse user table to differentiate user category.
And save user type during sign up and it's information.
I am also using this method because my application also has three end user.
This is working properly for me.
Hope this may helpful for you.