App Context API for Android SDK
This page describes App Context (formerly Objects v2). To upgrade from Objects v1, refer to the migration guide.
App Context provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use App Context to easily store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.
PubNub also triggers events when object data is changed: set, updated, or removed from the database. At the same time, making a request to set the same data that already exist, doesn't trigger any event. Clients can receive these events in real time and update their front-end application accordingly.
User
Get Metadata for All Users
Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.
Method(s)
To Get All UUID Metadata
you can use the following method(s) in the Android SDK:
pubnub.getAllUUIDMetadata()
.limit(Integer)
.page(PNPage)
.filter(String)
.sort(List<PNSortKey>)
.includeTotalCount(Boolean)
.includeCustom(Boolean)
Parameter | Description |
---|---|
limit Type: Integer Default: 100 | The maximum number of objects to retrieve at a time. |
page Type: PNPage Default: n/a | The paging object used for pagination. |
filter Type: String? Default: n/a | Expression used to filter the results. Only objects whose properties satisfy the given expression are returned. The filter language is defined here |
sort Type: List <PNSortKey> Default: n/a | List of properties to sort by. Available options are id , name , and updated . Use asc or desc to specify sort direction. For example: {name: 'asc'} |
includeTotalCount Type: Boolean Default: false | Request totalCount to be included in paginated response, which is omitted by default. |
includeCustom Type: Boolean Default: false | Whether to include the custom object in the fetch response. |
Basic Usage
pubnub.getAllUUIDMetadata()
.limit(20)
.sort(SortKey.asc(SortKey.Key.ID), SortKey.desc(SortKey.Key.UPDATED))
.includeTotalCount(true)
.includeCustom(true)
.async(new PNCallback<PNGetAllUUIDMetadataResult>() {
@Override
public void onResponse(@Nullable final PNGetAllUUIDMetadataResult result, @NotNull final PNStatus status) {
if (status.isError()) {
//handle error
}
else {
//handle result
}
}
show all 16 linesResponse
public class PNGetAllUUIDMetadataResult extends EntityArrayEnvelope<PNUUIDMetadata> {
Integer totalCount;
String next;
String prev;
int status;
List<PNUUIDMetadata> data;
PNPage nextPage() {
return PNPage.next(next);
}
PNPage previousPage() {
return PNPage.previous(prev);
}
}
public class PNUUIDMetadata extends PNObject {
show all 24 lines