public class CNContactStore extends NSObject
The CNContactStore is a thread safe class that can fetch and save contacts, fetch and save groups, and fetch containers.
[@note] Some good practices are: 1) Only fetch contact properties that will be used. 2) When fetching all contacts and caching the results, first fetch all contact identifiers only. Then fetch batches of detailed contacts by identifiers as you need them. 3) To aggregate several contact fetches collect a set of unique contact identifiers from the fetches. Then fetch batches of detailed contacts by identifiers. 4) When CNContactStoreDidChangeNotification is posted, if you cache any fetched contacts/groups/containers then they must be refetched and the old cached objects released.
| Modifier and Type | Class and Description |
|---|---|
static interface |
CNContactStore.Block_enumerateContactsWithFetchRequestErrorUsingBlock |
static interface |
CNContactStore.Block_requestAccessForEntityTypeCompletionHandler |
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
CNContactStore(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
accessInstanceVariablesDirectly() |
static CNContactStore |
alloc() |
static CNContactStore |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static long |
authorizationStatusForEntityType(long entityType)
Indicates the current authorization status to access contact data.
|
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument) |
static NSArray<java.lang.String> |
classFallbacksForKeyedArchiver() |
static org.moe.natj.objc.Class |
classForKeyedUnarchiver() |
NSArray<? extends CNContainer> |
containersMatchingPredicateError(NSPredicate predicate,
org.moe.natj.general.ptr.Ptr<NSError> error)
Fetch all containers matching a given predicate.
|
NSData |
currentHistoryToken()
The current history token.
|
static java.lang.String |
debugDescription_static() |
java.lang.String |
defaultContainerIdentifier()
The identifier of the default container.
|
static java.lang.String |
description_static() |
boolean |
enumerateContactsWithFetchRequestErrorUsingBlock(CNContactFetchRequest fetchRequest,
org.moe.natj.general.ptr.Ptr<NSError> error,
CNContactStore.Block_enumerateContactsWithFetchRequestErrorUsingBlock block)
Enumerates all contacts matching a contact fetch request.
|
CNFetchResult<NSEnumerator<CNChangeHistoryEvent>> |
enumeratorForChangeHistoryFetchRequestError(CNChangeHistoryFetchRequest request,
org.moe.natj.general.ptr.Ptr<NSError> error)
Enumerate a change history fetch request.
|
CNFetchResult<NSEnumerator<CNContact>> |
enumeratorForContactFetchRequestError(CNContactFetchRequest request,
org.moe.natj.general.ptr.Ptr<NSError> error)
Enumerate a contact fetch request.
|
boolean |
executeSaveRequestError(CNSaveRequest saveRequest,
org.moe.natj.general.ptr.Ptr<NSError> error)
Executes a save request.
|
NSArray<? extends CNGroup> |
groupsMatchingPredicateError(NSPredicate predicate,
org.moe.natj.general.ptr.Ptr<NSError> error)
Fetch all groups matching a given predicate.
|
static long |
hash_static() |
CNContactStore |
init() |
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
static CNContactStore |
new_objc() |
void |
requestAccessForEntityTypeCompletionHandler(long entityType,
CNContactStore.Block_requestAccessForEntityTypeCompletionHandler completionHandler)
Request access to the user's contacts.
|
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
static void |
setVersion_static(long aVersion) |
static org.moe.natj.objc.Class |
superclass_static() |
NSArray<? extends CNContact> |
unifiedContactsMatchingPredicateKeysToFetchError(NSPredicate predicate,
NSArray<?> keys,
org.moe.natj.general.ptr.Ptr<NSError> error)
Fetch all unified contacts matching a given predicate.
|
CNContact |
unifiedContactWithIdentifierKeysToFetchError(java.lang.String identifier,
NSArray<?> keys,
org.moe.natj.general.ptr.Ptr<NSError> error)
Fetch a unified contact with a given identifier.
|
static long |
version_static() |
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKeypublic static boolean accessInstanceVariablesDirectly()
public static CNContactStore alloc()
public static CNContactStore allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static long authorizationStatusForEntityType(long entityType)
Based upon the access, the application could display or hide its UI elements that would access any Contacts API. This method is thread safe.
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public static long hash_static()
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public static CNContactStore new_objc()
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public static void setVersion_static(long aVersion)
public static org.moe.natj.objc.Class superclass_static()
public static long version_static()
public NSArray<? extends CNContainer> containersMatchingPredicateError(NSPredicate predicate, org.moe.natj.general.ptr.Ptr<NSError> error)
Use only predicates from CNContainer+Predicates.h. Compound predicates are not supported.
predicate - The predicate to match against. Set to nil to match all containers.error - If an error occurs, contains error information.public java.lang.String defaultContainerIdentifier()
This identifier can be used to fetch the default container.
public boolean enumerateContactsWithFetchRequestErrorUsingBlock(CNContactFetchRequest fetchRequest, org.moe.natj.general.ptr.Ptr<NSError> error, CNContactStore.Block_enumerateContactsWithFetchRequestErrorUsingBlock block)
This method will wait until the enumeration is finished. If there are no results, the block is not called and YES is returned.
fetchRequest - The contact fetch request that specifies the search criteria.error - If an error occurs, contains error information.block - Called for each matching contact. Set *stop to YES to stop the enumeration.public boolean executeSaveRequestError(CNSaveRequest saveRequest, org.moe.natj.general.ptr.Ptr<NSError> error)
Do not access objects when save request is executing. A save request with contacts may modify the contacts while executing. A save request only applies the changes to the objects. If there are overlapping changes with multiple, concurrent CNSaveRequests then the last saved change wins.
saveRequest - Save request to execute.error - If an error occurs, contains error information.public NSArray<? extends CNGroup> groupsMatchingPredicateError(NSPredicate predicate, org.moe.natj.general.ptr.Ptr<NSError> error)
Use only predicates from CNGroup+Predicates.h. Compound predicates are not supported.
predicate - The predicate to match against. Set to nil to match all groups.error - If an error occurs, contains error information.public CNContactStore init()
public void requestAccessForEntityTypeCompletionHandler(long entityType,
CNContactStore.Block_requestAccessForEntityTypeCompletionHandler completionHandler)
Users are able to grant or deny access to contact data on a per-application basis. To request access to contact data, call requestAccessForEntityType:completionHandler:. This will not block the application while the user is being asked to grant or deny access. The user will only be prompted the first time access is requested; any subsequent CNContactStore calls will use the existing permissions. The completion handler is called on an arbitrary queue.
[@note] Recommended to use CNContactStore instance methods in this completion handler instead of the UI main thread. This method is optional when CNContactStore is used on a background thread. If it is not used in that case, CNContactStore will block if the user is asked to grant or deny access.
entityType - Set to CNEntityTypeContacts.completionHandler - This block is called upon completion. If the user grants access then granted is YES and error is nil. Otherwise granted is NO with an error.public CNContact unifiedContactWithIdentifierKeysToFetchError(java.lang.String identifier, NSArray<?> keys, org.moe.natj.general.ptr.Ptr<NSError> error)
Due to unification the returned contact may have a different identifier. To fetch a batch of contacts by identifiers use [CNContact predicateForContactsWithIdentifiers:].
identifier - The identifier of the contact to fetch.keys - The properties to fetch into the returned CNContact object. Should only fetch the properties that will be used. Can combine contact keys and contact key descriptors.error - If an error occurs, contains error information.public NSArray<? extends CNContact> unifiedContactsMatchingPredicateKeysToFetchError(NSPredicate predicate, NSArray<?> keys, org.moe.natj.general.ptr.Ptr<NSError> error)
Use only predicates from CNContact+Predicates.h. Compound predicates are not supported. Due to unification the returned contacts may have a different identifier.
[@note] To fetch all contacts use enumerateContactsWithFetchRequest:error:usingBlock:.
predicate - The predicate to match against.keys - The properties to fetch into the returned CNContact objects. Should only fetch the properties that will be used. Can combine contact keys and contact key descriptors.error - If an error occurs, contains error information.public NSData currentHistoryToken()
Retrieve the current history token. If you are fetching contacts or change history events, you should use the token on the @c CNFetchResult instead.
public CNFetchResult<NSEnumerator<CNChangeHistoryEvent>> enumeratorForChangeHistoryFetchRequestError(CNChangeHistoryFetchRequest request, org.moe.natj.general.ptr.Ptr<NSError> error)
Executes the given fetch request and returns an enumerator for the results. This may prevent all events from being loaded into memory at once.
An exception may be thrown if an error occurs during enumeration.
request - A description of the events to fetch.error - If the fetch fails, contains an @c NSError object with more information.public CNFetchResult<NSEnumerator<CNContact>> enumeratorForContactFetchRequestError(CNContactFetchRequest request, org.moe.natj.general.ptr.Ptr<NSError> error)
Executes the given fetch request and returns an enumerator for the results. This may prevent all records from being loaded into memory at once.
An exception may be thrown if an error occurs during enumeration.
request - A description of the records to fetch.error - If the fetch fails, contains an @c NSError object with more information.