Create anonymous highscorelistor in unity - unity3d

I have simple game on Google Play and Apple App Store that I have created in Unity. Now I am thinking about creating a global high score, so if you are in top 10 for example you can enter a made up user name.
The thing is I do not want the users to sign in since I want the game to be easy to access. One user can also enter a new username each time a record is beaten. So you can for example have the first three positions.
In principle, the app should read the high score from database and one should be able to write to it with {userID, new_score}, but no data is connected to any particular user. I am used to work with Firebase, what would be the easiest way to achieve this?
Thanks,
Erik

Well, the fact that you don't have data connected to any particular user do not means that you can't store the highscores. Cause one user can beat himself.
So if your database (I don't know if it's realtime or firestore) knows which are the top scores, when a user (indpendently of his ID) beats the score threshold, you can give him the option to put a name on that highscore, and update your database with this new score.
I will also recommend to bind users with data, his highscore or the name it's using to register the highscore, but you can achieve the same result without it.

You could try having a read and create only set of records, where write requires a valid anonymous auth key. I haven't tried that setup with Anonymous only auth before though.
Otherwise you could also try setting up a cloud function to validate and write the high score records.

Related

How to create a virtual coin system in my game using Firebase in Flutter?

I'd like to integrate in my Flutter app a credit system in which every user has his own balance of virtual coin, and of course they can earn coin while improving in the game. What are the main services should I use to enable this feature? Using Firestore Collections is enough?
Yes, I previously have done something like this using Firestore Collections, and store credit value for each user is enough. For each user, just add a new field 'credit' and set the balance for each user. You can get, add or subtract the value after.
Example

How to implement miles away like Tinder in Swift

I am trying to calculate how many miles away the user is from another user. Like on Tinder.
I am using Firebase to store all of the users data related to the app.
What would be the most secure way to do this without storing the actual users current location?
You need to get the current location, and after calculating the distance or after the user logs out, delete the location from the database. That is the only way to do it.
Note that this will work only if both users are online at the same time.

In SwiftUI, How do I use core data to store touch ID as an attribute of a person/class and record them?

I have looked at many tutorials on touchID and swiftUI but have all of them only use touchID as a boolean component to authenticate the user (The person is/is not authenticated). However, I am looking for a way to use touchID to identify the person with the ID, which is stored in the database. Thus, the process would be like so:
touchID -> program searches for touchID associated with a certain person -> record that the certain person has, for example, logged in by recording the person's other attribute, such as name.
For example, when the program prompts the user for his touch, if Jack touches the ID, the program can print("Jack has logged in"), while if Tom touches the ID, the program will print("Tom has logged in") by the idea of print("(name) has logged in") given that name is a state associated with the attribute stored in core data.
To sum up:
how to use touchID as an attribute in core data?
how to use touchID as an indicator of the object (or person in this case) stored in core data?
If touchID has no such feature, would it be possible to instead do the same with an external fingerprint scanning hardware? How would this work?
As I am a beginner in swiftUI and core data, I am sorry if the question seems to be common sense for more advanced coders. If there are any articles or links related, please provide them for me to see as well. Thank you very much
This is not possible with TouchID. As you have already pointed out correctly you can only get a boolean feedback. Everything else would clearly be a security breach if every App could receive and store TouchID-data from iOS and do with it whatever it wants.
Genereally speaking, to receive data from an external device and store it inside the App / upload it somewhere would be possible. But your question is so abstract that a more detailed answer is not possible.

Random profile images in Firebase

I would like to know, what would be the best approach for something like identicons and gravatar but in swift and to store them into Firebase and assign as profileImage.
Other thing I came up with, would be to make array of image url-s and while registering, randomly pick one url and store it. Is it OK to do?
Can you guys lead me to right direction?
I wouldn't recommend you holding all this data at once especially if you'll end up having multiple images. I would recommend one of the following
A single gravatar
Simply assign all newbie's profile image to this. You can even go ahead and store it inside your app so no need for a Firebase call or memory hogs.
Feature dependent
Try assigning gravatars based on specific fixed/factual characteristics of your users. Sex is the most preferable since its binary. Facebook uses the same approach when no profile image is added by the user. Should you opt for this method, Firebase is not really needed.
Dynamic
Multiple default avatars available and open to further addition. My guess is that you're interested in this one.
User selection
Have all of your avatars stored in Firebase and simply have the user select the most appealing to them.
Since you'll be adding more avatars in the future, then I'd advice against loading all of your avatars at once. For memory optimization,
Query for the first 10 avatars and present them to the user
If user hasn't selected avatar and let's say they are 3/4 through of the already loaded images, query for another 10 avatars.
This method is very memory friendly and it will not overwhelm the user with so much information.
Random selection
Have your avatars stored in Firebase Storage but also include a node in your Firebase database which tracks the number of avatars available. For this case lets call it total. Along with this I'd have a number-string to avatar url mapping in my avatar node. My structure would be something similar to this
{
"avatars":
{
"total":10,
"1":"https://www.google.com",
"2":"https://www.facebook.com",
"3":"https://www.youtube.com"
}
}
This begs the question, How do I randomly query for avatars?
Uhh huuh..
Query Firebase to get the number of avatars you currently have
Generate a random integer; say x which adheres to 1<=x<=total
Convert x to String; y = String(x)
Query Firebase where avatars.id == y and voila you have the imageURL
Download the image from imageURL
The downside to this is that the user has no control and should they hate their avatar there's nothing they can do about it.
The upside is that at any given moment you're NOT loading all of the images in memory.

Password login for ios app

I am currently developing an app for a company that is in a very competitive field. I have finished all of the features of the app that they requested except for one, making it somehow protected from their competing companies to download and use. I thought that I could set up a UIViewController with a password field that would check against some kind of database, but I'm not sure how to do the checking against a database part nor the practicality of it, and was hoping I could get some ideas on how to do this so that other companies couldn't steal and use this app without a password or something that changes like every 30 days or something and is kind of like an activation code.
Review the WWDC 2012 video "Building and Distributing Custom B2B Apps for iOS". I'm unsure if your app is in this B2B classification, it seems that it might be from your description.
What I ended up doing (if everyone needs a reference) was setting up a server with an SQL table that has pass codes in it. Since apple does not allow for any sort of system that requires you to "buy the app from outside the app store" I made a dumby username field (shame on me) that takes any value you like and then requires to have a pass code that fits. Once the pass code gets authenticated with the web server in a json sql request (there are plenty of api's to do this with) it comes back and sends the user to the first screen and sets a value in a plist with how many days of use the user has left. Whenever the user opens up the app it checks to see if the date is different from the last date logged in (saved in the same plist file) and if it is different then it calculates the difference and deducts that many. When the count reaches 0 it sends the user to the pass code authentication screen again. A bit complicated but an effective method of getting around Apple's restriction on not having a sort of pass code system like this. Thanks for the answers, unfortunately enterprise did not work for this company since they needed to be able to distribute the app to as many 3rd party members as they wanted to without having to worry about them leaving the company for other suppliers and remote management of the app (I.e ability to remote uninstall) was also not an option. Hope this helps someone someday!