Retrieving a Group

You can use the following methods to retrieve data of a group from your mobile app:

This topic explains how to retrieve a group by ID. For the second method, retrieving a group for its member or owner, see Relationship between a User and a Group.

You cannot reference an existing group by its name that was specified when the group was created. If you attempt to do so, a new group with the same name will be created.

This topic explains how to retrieve a group by ID.

In order to reference a group by its ID, get and save it somewhere just after the group is created.

  1. Get and save the ID

    When a group is created, save its ID in the location where the logged-in user can access.

    In this example, the ID string is saved with the ChatGroupID key in a KiiObject in the groupChatBucket bucket in the user scope. Instead of a bucket, you can also use OS-dependent storage, such as the shared preferences of Android and NSUserDefaults of iOS.

  2. Retrieve the ID

    Retrieve the ID with the ChatGroupID key for referencing the group.

  3. Reference the group by the ID

    Reference the group by its ID. The group in the original state can be restored on the client.

Retrieving a group by ID

Use the group ID to retrieve the existing group as follows:

curl -v -X GET \
  -H "Authorization: Bearer {ACCESS_TOKEN}" \
  "https://api.kii.com/api/apps/{APP_ID}/groups/{GROUP_ID}"

The group will be return as a 200 response:

< 200 OK
< Content-Type: application/vnd.kii.GroupRetrievalResponse+json;charset=UTF-8
<
{
  "groupID" : "{GROUP_ID}",
  "name" : "{GROUP_NAME}",
  "owner" : "{GROUP_OWNER_USER_ID}",
  "createdAt" : {CREATED_DATE},
  "modifiedAt" : {LAST_MODIFIED_DATE}
}