GARSession Class

GARSession Class Reference

Overview

ARCore session class.

Adds Google AR features to an app using ARKit.

Inherits NSObject.

Instance Method Summary

(instancetype) - NS_UNAVAILABLE
 Use sessionWithAPIKey:bundleIdentifier:error: to instantiate a GARSession. More...
 
(GARFrame *_Nullable) - update:error:
 Updates the GARSession with an ARFrame. More...
 
(void) - removeAnchor:
 Removes an anchor from the session. More...
 
(GARAnchor *_Nullable) - hostCloudAnchor:error:
 Hosts a new cloud anchor based on an ARAnchor. More...
 
(GARAnchor *_Nullable) - resolveCloudAnchorWithIdentifier:error:
 Resolves a cloud anchor. More...
 

Class Method Summary

(instancetype _Nullable) + sessionWithAPIKey:bundleIdentifier:error:
 Creates a GARSession with an API key and bundle identifier. More...
 
(instancetype) + NS_UNAVAILABLE
 

Property Summary

GARFramePaircurrentFramePair
 The most recent frame pair, containing the most recent ARFrame passed into update:error: and the corresponding returned GARFrame. More...
 
id< GARSessionDelegatedelegate
 The delegate for receiving callbacks about the GARSession. More...
 
dispatch_queue_t delegateQueue
 The dispatch queue on which the delegate receives calls. More...
 

Method Detail

+ (instancetype _Nullable) sessionWithAPIKey: (NSString *)  apiKey
bundleIdentifier: (NSString *_Nullable)  bundleIdentifier
error: (NSError **)  error 

Creates a GARSession with an API key and bundle identifier.

Parameters
apiKeyYour API key for Google Cloud Services.
bundleIdentifierThe bundle identifier associated to your API key. If nil, defaults to [[NSBundle mainBundle] bundleIdentifier].
errorOut parameter for an NSError. Possible errors: GARSessionErrorCodeDeviceNotCompatible - this device is not currently supported. GARSessionErrorCodeInvalidArgument - API key is nil or empty.
Returns
The new GARSession, or nil if there is an error.
- (instancetype) NS_UNAVAILABLE

Use sessionWithAPIKey:bundleIdentifier:error: to instantiate a GARSession.

- (GARFrame *_Nullable) update: (ARFrame *)  frame
error: (NSError **)  error 

Updates the GARSession with an ARFrame.

Call this method with every ARFrame to keep the sessions synced. Can be called on any thread. Normally, this should be called from your ARSessionDelegate's session:didUpdateFrame: method.

Parameters
frameThe next ARFrame from ARKit.
errorOut parameter for NSError. Possible errors: GARSessionErrorCodeInvalidArgument - invalid (nil) frame. GARSessionErrorCodeFrameOutOfOrder - frame has a smaller timestamp than previous.
Returns
The GARFrame corresponding to the ARFrame passed in, or nil if there is an error.
- (void) removeAnchor: (GARAnchor *)  anchor

Removes an anchor from the session.

Parameters
anchorThe anchor to remove.
- (GARAnchor *_Nullable) hostCloudAnchor: (ARAnchor *)  anchor
error: (NSError **)  error 

Hosts a new cloud anchor based on an ARAnchor.

Parameters
anchorThe ARAnchor to host.
errorOut parameter for an NSError. Possible errors: GARSessionErrorCodeInvalidArgument - invalid (nil) anchor. GARSessionErrorCodeNotTracking - bad current ARTrackingState.
Returns
The new GARAnchor, or nil if there is an error.
- (GARAnchor *_Nullable) resolveCloudAnchorWithIdentifier: (NSString *)  identifier
error: (NSError **)  error 

Resolves a cloud anchor.

The new anchor is immediately added to the session and returned, but without a valid transform. If resolving fails, the anchor will be automatically removed from the session.

Parameters
identifierThe cloud anchor identifier for the anchor.
errorOut parameter for an NSError. Possible errors: GARSessionErrorCodeInvalidArgument - invalid (nil or empty) identifier. GARSessionErrorCodeNotTracking - bad current ARTrackingState.
Returns
The new GARAnchor, or nil if there is an error.

Property Detail

- (GARFramePair*) currentFramePair
readatomicassign

The most recent frame pair, containing the most recent ARFrame passed into update:error: and the corresponding returned GARFrame.

- (id<GARSessionDelegate>) delegate
readwriteatomicweak

The delegate for receiving callbacks about the GARSession.

- (dispatch_queue_t) delegateQueue
readwriteatomicassign

The dispatch queue on which the delegate receives calls.

If nil, callbacks happen on the main thread.

Send feedback about...