How to create ParseUsers groups using Parse.com?

I am currently using Parse.com to create several ParseUsers. This works great, and each user can log in individually. However, from here I want to expand my application so that users can create user groups and, therefore, have data that is relevant only to these users. This will mean that when a user logs in, they can see a list of groups in which they are logged in, and from there they can simply share data with those users of this particular group. What would be the best way to handle this, and does anyone have examples or tutorials that I could follow to understand this concept?

I thought about creating a Group class, and then creating the identifiers of this repository in an array, and then allowing each user to store an array of identifiers for the groups in which they are currently members. I'm just not sure how to do this.

Thanks in advance!

+8
android grouping
source share
2 answers

I finished the job as below:

ParseQuery<ParseRole> query = ParseRole.getQuery(); Intent intent = getActivity().getIntent(); String groupId = intent.getStringExtra("groupId"); query.whereEqualTo("objectId", groupId); groupUsers = new ArrayList<String>(); query.findInBackground(new FindCallback<ParseRole>() { @Override public void done(List<ParseRole> objects, ParseException e) { if(e == null) { for(ParseRole role : objects) { ParseRelation<ParseUser> usersRelation = role.getRelation("users"); ParseQuery<ParseUser> usersQuery = usersRelation.getQuery(); usersQuery.findInBackground(new FindCallback<ParseUser>() { @Override public void done(List<ParseUser> objects, ParseException e) { for(ParseUser user : objects) { groupUsers.add(user.getUsername()); } } }); } } else { Toast.makeText(getActivity(), "ERROR", Toast.LENGTH_SHORT).show(); } } }); 

I passed the group ID from Intent , which sent me to this Fragment , which I checked, and then populated my ListView list, which I returned from the query in the Parse database using the specific group ID. Hope this helps anyone who has had the same problem as me. Good luck

+3
source share

Since you probably want to use it for security, as well as for ease of use of the code / users, take a look at the Role Protection Feature .

You can add / remove users from roles and assign ACL permissions for roles instead of users. Thus, when people are added / removed from a role, permissions do not require any changes.

Initially, there was a limit on the number of roles that you were allowed to create based on the type of account, but this restriction was removed last year, I suppose.

0
source share

All Articles