Add Presentation Sample
This commit is contained in:
Родитель
5e11e9a8c9
Коммит
74ed52e364
|
@ -10,6 +10,7 @@
|
|||
554E0BB1261E0D8D006A4403 /* VCSamples.h in Headers */ = {isa = PBXBuildFile; fileRef = 554E0BAF261E0D8D006A4403 /* VCSamples.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
554E0BBA261E0DAD006A4403 /* VCServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554E0BB9261E0DAD006A4403 /* VCServices.framework */; };
|
||||
554E0BBE261E0DBE006A4403 /* IssuanceSample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 554E0BBD261E0DBE006A4403 /* IssuanceSample.swift */; };
|
||||
554E0BC1261E1B88006A4403 /* PresentationSample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 554E0BC0261E1B88006A4403 /* PresentationSample.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
@ -18,6 +19,7 @@
|
|||
554E0BB0261E0D8D006A4403 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
554E0BB9261E0DAD006A4403 /* VCServices.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = VCServices.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
554E0BBD261E0DBE006A4403 /* IssuanceSample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssuanceSample.swift; sourceTree = "<group>"; };
|
||||
554E0BC0261E1B88006A4403 /* PresentationSample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationSample.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -55,6 +57,7 @@
|
|||
554E0BAF261E0D8D006A4403 /* VCSamples.h */,
|
||||
554E0BB0261E0D8D006A4403 /* Info.plist */,
|
||||
554E0BBD261E0DBE006A4403 /* IssuanceSample.swift */,
|
||||
554E0BC0261E1B88006A4403 /* PresentationSample.swift */,
|
||||
);
|
||||
path = VCSamples;
|
||||
sourceTree = "<group>";
|
||||
|
@ -147,6 +150,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
554E0BBE261E0DBE006A4403 /* IssuanceSample.swift in Sources */,
|
||||
554E0BC1261E1B88006A4403 /* PresentationSample.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import VCServices
|
||||
import VCEntities
|
||||
import PromiseKit
|
||||
|
||||
class PresentatonSample {
|
||||
|
||||
func presentationSample() {
|
||||
/// set up presentation service through dependency injection if you like.
|
||||
let presentationService = PresentationService()
|
||||
|
||||
presentationService.getRequest(usingUrl: "<presentation request url>").done { presentationRequest in
|
||||
self.handle(successfulRequest: presentationRequest, with: presentationService)
|
||||
}.catch { error in
|
||||
self.handle(failedRequest: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func handle(successfulRequest request: PresentationRequest, with service: PresentationService) {
|
||||
|
||||
let response: PresentationResponseContainer
|
||||
|
||||
do {
|
||||
response = try PresentationResponseContainer(from: request)
|
||||
} catch {
|
||||
VCSDKLog.sharedInstance.logError(message: "Unable to create PresentationResponseContainer.")
|
||||
return
|
||||
}
|
||||
|
||||
service.send(response: response).done { _ in
|
||||
self.handleSuccessfulResponse()
|
||||
}.catch { error in
|
||||
self.handle(failedResponse: error)
|
||||
}
|
||||
}
|
||||
|
||||
private func handleSuccessfulResponse() {
|
||||
/// handle successful presentation how you wish
|
||||
}
|
||||
|
||||
private func handle(failedRequest: Error) {
|
||||
VCSDKLog.sharedInstance.logError(message: "Unable to fetch request.")
|
||||
}
|
||||
|
||||
private func handle(failedResponse: Error) {
|
||||
VCSDKLog.sharedInstance.logError(message: "Unable to send presentation response.")
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче