Write cloud code in Parse to check for unique username - Android - android

I am trying to check if an username is unique in the Installation class of my Parse collection. I figured out that the installation class cannot be queried like the normal classes and should be cloud coded to obtain result.
I had seen this post. How to check Unique fields in a class using cloud code. I don't know how to replace this with what I require and make a call from my android device.
My requirement is that, I just need to check if a given username is already present in the Installation class or not.
Thanks in advance.

Best way is probably the one described in the post you linked to. You shouldn't try to determine the uniqueness of the name on the device - you should do it on the server side while creating a new instance of your installation class, and return an error to the app if it tries to create a username that already exists (like in the example you posted).

Related

Get unique ANDROID_ID on flutter is it possible?

I would like to get the unique device id on android with Flutter.
I've tried this plugin device_info but it doesn't return the ANDROID_ID that I get in java Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
how can I get the same id?
In this case it might be simpler using platform specific code and a Flutter platform channel setup.
You can then use your Java code as included in your question and pass the Android ID to your Flutter application via a platform channel when needed.
See Writing custom platform-specific code with platform channels .
You can do what you did, but it is not reliable or guaranteed. Please read up on:
https://developer.android.com/training/articles/user-data-ids
for best handling of unique IDs.
Of course you can get the phone network ID, but what if that device doesn't have a carrier.
You could get the device ID, but what if it returns null for that manufacturer.
You could get the Advertiser ID, and this is often recommended, but it CAN CHANGE, it is unlikely to change, but if they do a factory reset or anything like that, it would.
So your best bet might be to generate your own unique IDs and store them locally with the application either in a DB implementation or SharedPreferences.
So to answer your question, if you have existing audience that you used the wrong, bad practice way of using unique IDs, then you should make an ID factory with if/else logic to fix it.
If (first time accessing an ID for this installed application)
//createOne and store it
else if(ID already exists and matches ANDROID_SECURE_ID method)
//get it the old way,
//create new one, and update your access to APIs or DB with new associated ID so that you never hit this code path again
else
//use correct ID implementation that you created
You could also just as easily do a one time check in your Application onCreate to fix anyone with wrong ID and then set a flag that you fixed it so you don't fix it again in sharedpref.

How to make api.ai agent learn something dynamically?

I am currently using api.ai , to create agent to perform specific tasks, but one question i don't have answer to is , can i make it learn something while chatting , mean that i speak my name is 'John Cena' and she should store it and then whenever i ask her again bot should answer me that. i know there is a way to do it by logging into api.ai web and manually add entries , but it will not help, is there any work around programmatically or automatically ? the file i've been using to practice is given in github . and here is working DEMO
You basically need for your bot to "learn" facts. There are many different ways to achieve this, but recently the most common way is to arrange knowledge into Semantic "Triples" and store the knowledge into a Graph repository (like Neo4j, Titan, Spark Graph, etc). In your example, "my name is John Cena" would translate into a Triple like ("anubava","Name","John Cena"). That way, the next time you are logged in as anubhava and ask "What is my name?", it would translate into a Graph search that will return "John Cena". A word of caution, achieving this is not trivial and would require some significant amount of fine tuning. For more info, you can check here and here.
Finally, most complete solutions (that I know of), are Server Side solutions. If you want for the whole knowledge base to reside in your mobile device, you could probably use the resources there as inspiration, and build your own Linked Data repository using an embedded database.
Hope this helps. Good luck.
To store and recall the user's name, you'll need to set up a webhook with some basic data persistence capabilities. Any database or key-value store would work fine.
Here's the breakdown:
Implement webhook fulfillment for the intent that captures the user's name. The webhook should store the name along with a unique, identifying ID that you should supply from your front-end in either the sessionId or as a context parameter in your call to /query.
Implement webhook fulfillment for the intent that reads the user's name. The webhook should look up the name by ID and return a response that tells the user their name.
The high-level docs for writing a fulfillment webhook are here:
https://docs.api.ai/docs/webhook

Quickblox: Sign in using custom objects(Android)

I want to store more information about my user, hence quickblox user module will not be sufficient for me.
So I am using custom object to store all user information.
Can anyone please suggest (If possible with code) how do i sign in using custom object data structure i.e. How to check for correct username n password match from all records available..If match found then allow user to sign in else not...
I think it maybe using getFields() of Class QBCustomObject... but how to use that method???
Thanks in advance !!
Unfortunately you cannot refuse using QBUser. Both password and login will be stored in it. Each custom object has User Id field, so you can use it to connect user and custom object with data. Every time you create an object this field filled in with ID of a user who create this object. That is why you can create a table in custom objects and add all required fields.

Put some values on internet to access from android

In my app a user can (only) see the values uploaded by admin.
For example. A salesman is using the app will be able to see the latest rate provided by the manger to trade.
Now the question is "where to put these values?"
I have .net webservice experience with android but I guess it wont work in this scenario,will it?
Any suggestion that the returned result be in (preferably) XML format.
It sounds like you already know how to do this. You can download and parse xml within your app. If you alreayd know how to set up the websever, the rest is easy. Limiting who can see what is just a matter of associating specific transactions with an individuals account. Then just have the phone check for updates on that transaction when the app loads (using someting like AsyncTask) or if you want to get more complicated you could push notificatinos using the android cloud service, or even use a REST model. More details are needed for a more specific answer but you can do what you want.
You can do it on your own, and build a webserver with a MySQL/PHP JSON API or you can use parse.com for a smaller project.

Android new Application (registration process)

I built an android application that registers the user with its username/Password/phoneNumber.
if the user is registered in the DB, he can see the other menus for the application.
How can i check if the user is registered or not on the application ? There is a good way to do that (propose the registration process or application menu) ?
Thanks
I would advise you to use JSON method you'll have to add php file in order to send the data from the android application to your database ( you'll make an Insert into for a registration or just a Select for an existing user in you php file) then JSON method take back the data to android and return TRUE or false I know it's vague but there's lot of tutorial on this method. Hope it helped.
I'm not entirely sure of what you mean by "how can I check if the user is registered" when you just said the information is stored in a DB.
So... Based on the information you provided, you can do a couple things:
Check the DB to see if the user exists / is registered.
Use SharePreferences to store a variable saying whether or not the user has registered and then acting based on that information: http://developer.android.com/reference/android/content/SharedPreferences.html

Categories

Resources