Class

CloudKit.Container

A CloudKit.Container object provides access to an app container, and through the app container, access to its databases. It also contains methods for authenticating and fetching users.

Declaration

interface CloudKit.Container

Overview

You do not create container objects yourself, nor should you subclass the CloudKit.Container class. You configure a container using the CloudKit.configure method and obtain a container using one of the CloudKit namespace container methods.

The asynchronous methods in this class return a Promise object that resolves when the operation completes. For a description of the Promise class returned by these methods, go to Mozilla Developer Network: Promise.

This class is similar to the CKContainer class in the CloudKit framework.

Topics

Getting the Public and Private Databases

publicCloudDatabase

The database containing the data shared by all users.

privateCloudDatabase

The database containing the user’s private data.

sharedCloudDatabase

The database containing shared records accepted by the current user.

getDatabaseWithDatabaseScope

Returns the specified (public, private, or shared) database.

Getting the Identifier and Environment

containerIdentifier

The string that identifies the app’s container.

environment

The container environment, either development or production.

apnsEnvironment

The Apple Push Notification service (APNs) environment associated with this container.

Authenticating Users

setUpAuth

Determines whether a user is signed in and presents an appropriate sign in or sign out button.

whenUserSignsIn

Returns an object representing a deferred or asynchronous operation that resolves when the user signs in.

whenUserSignsOut

Returns an object representing a deferred or asynchronous operation that resolves when the user signs out.

Discovering Users

fetchCurrentUserIdentity

Fetches information about the current user asynchronously.

discoverAllUserIdentities

Fetches all user identities in the current user’s address book.

discoverUserIdentities

Fetches all users in the specified array.

discoverUserIdentityWithEmailAddress

Fetches information about a single user based on the user’s email address.

discoverUserIdentityWithPhoneNumber

Fetches information about a single user based on the user’s phone number.

discoverUserIdentityWithUserRecordName

Fetches information about a single user using the record name.

Accepting Shared Records

acceptShares

Accepts a share—that is represented by a shortGUID—on behalf of the current user.

fetchRecordInfos

Returns information about a record for which you have a shortGUID property.

Receiving Notifications

addNotificationListener

Adds a function to call when a push notification occurs.

removeNotificationListener

Removes a function to call when a push notification occurs.

registerForNotifications

Registers to receive push notifications.

unregisterForNotifications

Unregisters to receive push notifications.

isRegisteredForNotifications

Boolean value indicating whether this container is registered to receive push notifications.

Logging

toString

Returns a string representation of this CloudKit.Container object.