Is it possible to change automatically selected user property in Firebase - android

Firebase SDK automatically collects some of the important and common user properties. Which can be found here.
In our app and website, we auto-detect the user's country. We also allow the user to change it to their preferred country if needed. We are using this country value for providing more localized content.
The current problem which we are facing now is, the auto-detected country is mostly the same as Firebase automatically select country (user property). But if the user manually changes the country to a different one in the app, the country in Firebase and app won't match. Which is leading to lot of inconsistencies. For example, assume the user changed the country from IN to the US in the app. And from the Firebase dashboard, we send push notification targeting Indian users, the push notification will also be received by the above user, which is not correct.
To solve this problem we came up with 2 solutions,
Create a new custom user property called app_selected_country. This is a great solution, but we can't use this property immediately because of old & existing users won't be having this value without they update and use the app.
If we can change the automatically logged user property programmatically from the app and website, we could update the country user property to the app's country.
Our preferred option is the 2nd one. Because we'll be able to use the country user property the same as before. Even if the users won't update the app, we'll be able to use this property with existing data errors, which is fine for us.
The challenge with this approach is that we can't find any documentation regarding updating automatically logged user property.
So can you please help me answer these questions,
Is it possible to update automatically logged user property in Firebase? If so what is the user property key for the country?
Is there any side effect of doing this? We are a bit worried because we are changing the value detected by Firebase.

Unfortunately there is no way to change the auto-detected country. You will need to use your first proposed solution.

Related

How to remeber users without sign up in android?

Im working on a project where a user isn´t forced to sign up a account.
My plan is that a user could do anything like a user that is registered except for a few exceptions.
I implement a like function which saves the users behaviour on a webserver and later when the data is fetched again it recognized if the user liked something or not. My problem is that I have to save this informations also if the user isn´t registered to my application. A User should be free to decide wheter the user likes to sign up or not and isn´t forced to be a registered user.
I found three different way that could work!
1. Option
First option would be the accountmanager but I don´t like this option at all cause I have to ask for the contact permission and also ask which account a user want to use.
2. Option
A other option would be if a user starts the app for the very first time the app would call a server which creates a random unique code and send that code to my application to save it as key for the users actions which is saved on a server. But that also doesn´t seems to be a good solution for my problem.
3. Option
The last option would be oauth but for now I don´t know if and how it would be the solution to my problem!
I would be thankful for every answer!
I have worked on a comic app that requires saving the user subscribed channels, genre or comics and save the likes/dislikes for the same. User can be subscribed to push notification too.
For this, we used Firebase Authentication (anonymous signup). And to save the user subscription information, we used Firebase Firestore.
And followed the below approach.
As soon as the app opens, check if the user has already anonymous SignIn. If it hasn't, signUp silently.
Add a listener for user push notification token change. And update it to Firestore by anonymous user-id as key (We did same for storing other information too).
I think this approach would help to solve this problem.
You could use firebase auth for that!
Usually, you would use it with email & password or google login but it also has an anonymous login feature that should save the user's phone.
There are few techniques. It depends on whether you want to recognise a user between installations of app. If you are OK to lose a user on reinstallation you can use Firebase installation ID and link users behaviour with this id. If you want to remember users even between installations you can use unique to each combination of app-signing key, user, and device Secure.ANDROID_ID(more info about ids). But still the best way is implementing your own signing in or using of AccountManager.

How to "flag" users in firebase?

I have developed an android "Group Chat" app. Me and 20 of my friends are using this app to group chat with each other. When I look at the firebase database, I obviously see 21 users (including myself). However, I can't know whether all of them actually have the app installed on their phones, or some of them have uninstalled it. Is there any way I can differentiate among my uses? Generally speaking, can I "flag" my users as, say, active, inactive, and the like?
What is if you add a timestamp every time a use log in. With this timestamp you can see how long the user not log in and so if he is in active for a long time or not. It's not say if the user have delete the app. It's only a prognosis.
If i understand correctly your question, it can be split in two parts.
First part is whether you want to know if your users are online or offline this could be achieved by an online presence system as described here
The second part is whether or not users have installed or uninstalled your app.
In my opinion easiest way to do this is by using the Firebase Analytics SDK. This way you can check the app_remove stats and whenever a user uninstalls an app, it gets updated in the console under events section.
This will give you how many devices uninstalled the app and some info on country, gender and age of the user but you could couple this with a "last login" timestamp to pinpoint the exact user.
More details along with how to include analytics SDK to your app can be found here
Or you can use the .info/connected to have this functionality in your client code. You can read more info about this here and the sample presence app at the bottom of the page will help you get a grip on how to do it.
One possible solution is to add a flag in the database as the child of the user. This flag will have an initial value of active.
And instead of uninstalling the app directly, you can have a delete account functionality in the app, and whenever someone wants to delete his/her account, it simply updates the flag to inactive in firebase database.
Now you will know actually who is active / inactive.

Adding translations in Firebase push notifications

I am trying to localise the Push notifications that i receive on my Android/iOS device using Firebase notifications. I see an option in console to filter language, but i couldn't find any documentation pointing as to how i can use it? I need to know two things.
How can i add a new language to the list?
How can i handle this on device or is it handled automatically based on device language?
I have tried the following options.
Changing the device language and subscribing to a topic.
Adding a language suffix to the topic subscribed as - "userloggedin-fr"
But the above two options doesn't seem to work. I do not need to handle this manually using an additional key in payload. Can someone guide me how can i use the default option in console? I am including below a screenshot of my console right now. I am not sure how the "Spanish" got added into the list.
I can't tell you how to manage that on app side, but I can tell you how to get more languages to the list on firebase console. Firebase recognizes your app and the device language automatically and adds it to the list. So if your app is used by a user in a foreign country with a different language it is added automatically to your console.
You just misunderstood this field.
As oficial docs says
You can target user segments based on app, app version, language or user properties in ways that are not available using the to field in the server API.
So it's not the message language. It is group target based on app language

Android: Get Gender & Age

I'm looking for an easy way to get user's gender & age programmatically without any user input. I do not want to trouble the user with any sort of sign-ins to G+, FB or Twitter.
Just need a quick and easy way to get gender & age.
Is there any way to get user's gender and age without requiring any account sign-ins?
Are there any SDK's that would give this info without sign-ins?
There isn't any. You have interact with user to get the details, either by sign in or asking by yourself.
In some cases, you can however get some details, there is a contact, called as User which a few users fill. It might have the information you require but it is mostly empty.
But you shouldn't use this as it might be against user's will. You should use sign in or input fields.
If you are only looking for getting this information for statistical purposes, I'd recommend using Firebase analytics. Firebase automatically gives you age and gender distributions of your users.
https://firebase.google.com/docs/analytics/
You can't get any information without the user giving them to you (either with stating them in the app or giving you permission to take them). As #Sahil stated, IF the user has a contact with that information in order to take them you must get contacts permissions, which is not very smart having in mind that you only need users age and gender. The best way is to have a dialog or something similar where the user will state this informations.

Facebook - default app visibility and info missing in insights

I am working on getting our app into good shape Facebook-wise and there are two issues I cannot seem to figure out no matter how hard I try.
Is there any way to change the Default App Visibility? When our users sign up with Facebook, the default app visibility is set to Only Me. Is there any way to change this or does it depend on user's personal settings? Or can it be done from the mobile app somewhere in the e.g. Facebook SDK session?
We have been using Facebook for a while and in the Insights under the Login tab, there is the Demographics of New Facebook Logins section. I can see still the Geography data but for Gender & Age I now get No data is available for the current selection. even though I swear it worked about a month ago or so. Any ideas?
Any kind of advice or help is more than appreciated, seriously!
If you're only requesting read permissions, then there's no way to change the default audience (it's not really meaningful anyways in that case). If you're requesting publish permissions (like publish_actions), then you can set a default audience when you're making the request. See https://developers.facebook.com/docs/reference/android/current/class/Session.NewPermissionsRequest/#setDefaultAudience This can only be done once, and the user can always change it to a different setting later or deny that request, so you should not rely on it being the value that you chose in code. There's also no way to see or detect (from your app) what the user changed it to later, this is by design.
You're likely getting "No data is available" because there's not enough usage (or individual users) in that date range to generate a breakdown. This is to protect user privacy.

Categories

Resources