Package apple.contacts
Class CNContactStore
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.contacts.CNContactStore
-
- All Implemented Interfaces:
NSObject
public class CNContactStore extends NSObject
Provides methods to fetch and save contacts. 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCNContactStore.Block_enumerateContactsWithFetchRequestErrorUsingBlockstatic interfaceCNContactStore.Block_requestAccessForEntityTypeCompletionHandler-
Nested classes/interfaces inherited from class apple.NSObject
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCNContactStore(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanaccessInstanceVariablesDirectly()static CNContactStorealloc()static java.lang.ObjectallocWithZone(org.moe.natj.general.ptr.VoidPtr zone)static longauthorizationStatusForEntityType(long entityType)Indicates the current authorization status to access contact data.static booleanautomaticallyNotifiesObserversForKey(java.lang.String key)static voidcancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)static voidcancelPreviousPerformRequestsWithTargetSelectorObject(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.ClassclassForKeyedUnarchiver()NSArray<? extends CNContainer>containersMatchingPredicateError(NSPredicate predicate, org.moe.natj.general.ptr.Ptr<NSError> error)Fetch all containers matching a given predicate.NSDatacurrentHistoryToken()The current history token.static java.lang.StringdebugDescription_static()java.lang.StringdefaultContainerIdentifier()The identifier of the default container.static java.lang.Stringdescription_static()booleanenumerateContactsWithFetchRequestErrorUsingBlock(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.booleanexecuteSaveRequestError(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 longhash_static()CNContactStoreinit()static NSObject.Function_instanceMethodForSelector_retinstanceMethodForSelector(org.moe.natj.objc.SEL aSelector)static NSMethodSignatureinstanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)static booleaninstancesRespondToSelector(org.moe.natj.objc.SEL aSelector)static booleanisSubclassOfClass(org.moe.natj.objc.Class aClass)static NSSet<java.lang.String>keyPathsForValuesAffectingValueForKey(java.lang.String key)static java.lang.Objectnew_objc()voidrequestAccessForEntityTypeCompletionHandler(long entityType, CNContactStore.Block_requestAccessForEntityTypeCompletionHandler completionHandler)Request access to the user's contacts.static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)static voidsetVersion_static(long aVersion)static org.moe.natj.objc.Classsuperclass_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.CNContactunifiedContactWithIdentifierKeysToFetchError(java.lang.String identifier, NSArray<?> keys, org.moe.natj.general.ptr.Ptr<NSError> error)Fetch a unified contact with a given identifier.static longversion_static()-
Methods inherited from class apple.NSObject
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, willChangeValuesAtIndexesForKey
-
-
-
-
Method Detail
-
accessInstanceVariablesDirectly
public static boolean accessInstanceVariablesDirectly()
-
alloc
public static CNContactStore alloc()
-
allocWithZone
public static java.lang.Object allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
-
authorizationStatusForEntityType
public static long authorizationStatusForEntityType(long entityType)
Indicates the current authorization status to access contact data. Based upon the access, the application could display or hide its UI elements that would access any Contacts API. This method is thread safe.- Returns:
- Returns the authorization status for the given entityType.
-
automaticallyNotifiesObserversForKey
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
-
cancelPreviousPerformRequestsWithTarget
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
-
cancelPreviousPerformRequestsWithTargetSelectorObject
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)
-
classFallbacksForKeyedArchiver
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
-
classForKeyedUnarchiver
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
hash_static
public static long hash_static()
-
instanceMethodForSelector
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
-
instanceMethodSignatureForSelector
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
-
instancesRespondToSelector
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
-
isSubclassOfClass
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
-
keyPathsForValuesAffectingValueForKey
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
-
new_objc
public static java.lang.Object new_objc()
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
setVersion_static
public static void setVersion_static(long aVersion)
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
version_static
public static long version_static()
-
containersMatchingPredicateError
public NSArray<? extends CNContainer> containersMatchingPredicateError(NSPredicate predicate, org.moe.natj.general.ptr.Ptr<NSError> error)
Fetch all containers matching a given predicate. Use only predicates from CNContainer+Predicates.h. Compound predicates are not supported.- Parameters:
predicate- The predicate to match against. Set to nil to match all containers.error- If an error occurs, contains error information.- Returns:
- An array of CNContainer objects matching the predicate. If no matches are found, an empty array is returned. If an error occurs, nil is returned.
-
defaultContainerIdentifier
public java.lang.String defaultContainerIdentifier()
The identifier of the default container. This identifier can be used to fetch the default container.- Returns:
- The identifier of the default container. If the caller lacks Contacts authorization or an error occurs, nil is returned.
-
enumerateContactsWithFetchRequestErrorUsingBlock
public boolean enumerateContactsWithFetchRequestErrorUsingBlock(CNContactFetchRequest fetchRequest, org.moe.natj.general.ptr.Ptr<NSError> error, CNContactStore.Block_enumerateContactsWithFetchRequestErrorUsingBlock block)
Enumerates all contacts matching a contact fetch request. This method will wait until the enumeration is finished. If there are no results, the block is not called and YES is returned.- Parameters:
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.- Returns:
- YES if successful, otherwise NO.
-
executeSaveRequestError
public boolean executeSaveRequestError(CNSaveRequest saveRequest, org.moe.natj.general.ptr.Ptr<NSError> error)
Executes a save request. 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.- Parameters:
saveRequest- Save request to execute.error- If an error occurs, contains error information.- Returns:
- YES if successful, otherwise NO.
-
groupsMatchingPredicateError
public NSArray<? extends CNGroup> groupsMatchingPredicateError(NSPredicate predicate, org.moe.natj.general.ptr.Ptr<NSError> error)
Fetch all groups matching a given predicate. Use only predicates from CNGroup+Predicates.h. Compound predicates are not supported.- Parameters:
predicate- The predicate to match against. Set to nil to match all groups.error- If an error occurs, contains error information.- Returns:
- An array of CNGroup objects matching the predicate. If no matches are found, an empty array is returned. If an error occurs, nil is returned.
-
init
public CNContactStore init()
-
requestAccessForEntityTypeCompletionHandler
public void requestAccessForEntityTypeCompletionHandler(long entityType, CNContactStore.Block_requestAccessForEntityTypeCompletionHandler completionHandler)Request access to the user's contacts. 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.- Parameters:
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.
-
unifiedContactWithIdentifierKeysToFetchError
public CNContact unifiedContactWithIdentifierKeysToFetchError(java.lang.String identifier, NSArray<?> keys, org.moe.natj.general.ptr.Ptr<NSError> error)
Fetch a unified contact with a given identifier. Due to unification the returned contact may have a different identifier. To fetch a batch of contacts by identifiers use [CNContact predicateForContactsWithIdentifiers:].- Parameters:
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.- Returns:
- The unified contact matching or linked to the identifier. If no contact with the given identifier is found, nil is returned and error is set to CNErrorCodeRecordDoesNotExist.
-
unifiedContactsMatchingPredicateKeysToFetchError
public NSArray<? extends CNContact> unifiedContactsMatchingPredicateKeysToFetchError(NSPredicate predicate, NSArray<?> keys, org.moe.natj.general.ptr.Ptr<NSError> error)
Fetch all unified contacts matching a given predicate. 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:.- Parameters:
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.- Returns:
- An array of CNContact objects matching the predicate. If no matches are found, an empty array is returned. If an error occurs, nil is returned.
-
currentHistoryToken
public NSData currentHistoryToken()
The current history token. Retrieve the current history token. If you are fetching contacts or change history events, you should use the token on the @c CNFetchResult instead.
-
enumeratorForChangeHistoryFetchRequestError
public CNFetchResult<NSEnumerator<CNChangeHistoryEvent>> enumeratorForChangeHistoryFetchRequestError(CNChangeHistoryFetchRequest request, org.moe.natj.general.ptr.Ptr<NSError> error)
Enumerate a change history fetch request. 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.- Parameters:
request- A description of the events to fetch.error- If the fetch fails, contains an @c NSError object with more information.- Returns:
- An enumerator of the events matching the result, or @c nil if there was an error.
-
enumeratorForContactFetchRequestError
public CNFetchResult<NSEnumerator<CNContact>> enumeratorForContactFetchRequestError(CNContactFetchRequest request, org.moe.natj.general.ptr.Ptr<NSError> error)
Enumerate a contact fetch request. 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.- Parameters:
request- A description of the records to fetch.error- If the fetch fails, contains an @c NSError object with more information.- Returns:
- An enumerator of the records matching the result, or @c nil if there was an error.
-
-