Instance Property

ubiquityIdentityToken

An opaque token that represents the current user’s iCloud identity

Declaration

@property(readonly, copy) id<NSObject, NSCopying, NSCoding> ubiquityIdentityToken;

Discussion

When iCloud is currently available, this property contains an opaque object representing the identity of the current user. If iCloud is unavailable for any reason or there is no logged-in user, the value of this property is nil. Accessing the value of this property is relatively fast so you can check the value at launch time from your app’s main thread.

You can use the token in this property, together with the NSUbiquityIdentityDidChangeNotification notification, to detect when the user logs in or out of iCloud and to detect changes to the active iCloud account. When the user logs in with a different iCloud account, the identity token changes and the system posts the notification. If you stored or archived the previous token, compare that token to the newly obtained one using the isEqual: method to determine if the users are the same or different.

Accessing the token in this property does not connect your app to its ubiquity containers. To establish access to a ubiquity container, call the URLForUbiquityContainerIdentifier: method. In macOS, you can instead use an NSDocument object, which establishes access automatically.

See Also

Related Symbols

- URLForUbiquityContainerIdentifier:

Returns the URL for the iCloud container associated with the specified identifier and establishes access to that container.