ServiceStrategy
public class ServiceStrategy<CardItem> : ObservableObject, AsyncAnnotationLoadingStrategy where CardItem : CardItemModel, CardItem : Decodable, CardItem : Encodable
A loading strategy that makes a network fetch request to Mobile Services to return the data necessary to display an AR Annotation Scene. This strategy wraps the anchors that represents these locations with the CardItemModels that they correspond to in a ScreenAnnotation struct for a single source of truth. Loading the data into the ARAnnotationViewModel should be done in the onAppear method.
Usage
@StateObject var serviceStrategy = ServiceStrategy<CodableCardItem>(
serviceURL: URL(string: IntegrationTest.System.redirectURL)!,
sapURLSession: SAPURLSession.createOAuthURLSession(
clientID: IntegrationTest.System.clientID,
authURL: IntegrationTest.System.authURL,
redirectURL: IntegrationTest.System.redirectURL,
tokenURL: IntegrationTest.System.tokenURL
),
sceneIdentifier: SceneIdentifyingAttribute.id(IntegrationTest.TestData.sceneId)
arModel.loadAsync(loadingStrategy: serviceStrategy)
-
Unique attribute and its value identifiying a scene stored in SAP Mobile Services
Declaration
Swift
public var sceneIdentifier: SceneIdentifyingAttribute
-
Initializer
Declaration
Swift
public init(serviceURL: URL, sapURLSession: SAPURLSession, sceneIdentifier: SceneIdentifyingAttribute)
Parameters
serviceURL
Server URL for your application in SAP Mobile Services
sapURLSession
networking API from SAPFoundation framework
sceneIdentifier
unique value identifiying a scene stored in SAP Mobile Services
-
Performs network requests to load scene information from SAP Mobile Services
Declaration
Swift
public func load(with manager: ARManager, completionHandler: @escaping ([ScreenAnnotation<CodableCardItem>], GuideImageState) -> Void) throws
Parameters
manager
handling the ARView
completionHandler
providing the cards and image anchor of the requested scene once loaded