gpt4 book ai didi

ios - 无法使用在线签名模式创建信封

转载 作者:行者123 更新时间:2023-12-04 07:51:12 26 4
gpt4 key购买 nike

我正在尝试创建一个信封并使用在线模式对其进行签名。
起初,我登录到我的帐户

@IBAction private func signDocument(_ sender: UIButton) {
guard let hostURL = URL(string: Environment.current.docuSignHost) else { return }
isLoading = true
DSMManager.login(withEmail: Environment.current.docuSignUserID,
password: Environment.current.docuSignPass,
integratorKey: Environment.current.docuSignIntegratorKey,
host: hostURL) { [weak self] info, error in
self?.isLoading = false
if let error = error {
self?.error = error
} else {
self?.showDocuSign(info: info)
}
}
}

// MARK: - Helpers

private func showDocuSign(info: DSMAccountInfo?) {
guard let info = info else { return }
envelopManager.perform(with: info, presentingController: self)
}
之后,我创建了我的测试信封:
final class EnvelopeManager {

private let envelopesManager = DSMEnvelopesManager()
private let templateManager = DSMTemplatesManager()

// MARK: - Lifecycle

func perform(with config: DSMAccountInfo, presentingController: UIViewController) {
guard let documentURL = R.file.tgkCapitalPortfolioBAgreementPdf(),
let documentData = try? Data(contentsOf: documentURL) else { return }

let envelopDefinition = DSMEnvelopeDefinition()
envelopDefinition.envelopeName = "Some name"
envelopDefinition.emailSubject = "Please Sign Envelope on Document"
envelopDefinition.emailBlurb = "Hello, Please sign my Envelope"

let document = DSMDocument()
document.name = R.file.tgkCapitalPortfolioBAgreementPdf.name
document.documentId = "1"
document.documentBase64 = documentData.base64EncodedString()

envelopDefinition.documents = [document]

let signHere = DSMSignHere()
signHere.documentId = document.documentId
signHere.pageNumber = 1
signHere.recipientId = "1"
signHere.anchorXOffset = 100
signHere.anchorYOffset = 100
signHere.tabId = "1"

let tabs = DSMTabs()
tabs.signHereTabs = [signHere]

let signer = DSMSigner()
signer.canSignOffline = false
signer.email = config.email
signer.name = config.userName
signer.recipientId = "1"
signer.tabs = tabs

let signers: [DSMSigner] = [signer]

let recipients = DSMRecipients()
recipients.signers = signers

envelopDefinition.recipients = recipients
envelopDefinition.status = "sent"

envelopesManager.composeEnvelope(with: envelopDefinition, signingMode: .online) { [weak self] envelopID, error in
if let envelopID = envelopID {
print(envelopID)
self?.presentSigning(presenter: presentingController,
envelopeID: envelopID)
} else {
print(error.localizedDescription)
}
}
}

private func presentSigning(presenter: UIViewController, envelopeID: String) {
envelopesManager.presentSigning(withPresenting: presenter,
envelopeId: envelopeID,
animated: true) { (viewController, error) in
if let viewController = viewController {
print(viewController)
}

if let error = error {
print(error.localizedDescription)
}
}
}
}
但在这里
envelopesManager.composeEnvelope(with: envelopDefinition, signingMode: .online) { [weak self] envelopID, error in
if let envelopID = envelopID {
print(envelopID)
self?.presentSigning(presenter: presentingController,
envelopeID: envelopID)
} else {
print(error.localizedDescription)
}
}
我有一个错误:

Envelope creation online is not supported at this moment. Please tryoffline mode


当我切换到离线模式时,我无法使用该方法
envelopesManager.presentSigning(withPresenting:, enveloped: , animated:, completeion)
因为它仅适用于在线模式下创建的信封。在我的情况下,没有执行完成块。
如何解决这个问题?如何在在线模式下创建信封并签名?我做错了什么?我只想选择包含在项目包中的 pdf 并在某个位置添加符号。
提供的示例项目 here不符合我的要求。因为使用来自服务器的模板并通过 presentComposeEnvelopeController 创建信封选择文件等的方法
XCode 12.4、iOS 13/14、DocuSign 2.4.1 通过 CocoaPods 包含在项目中。
编辑1
我更新了我的 perform方法:
func perform(with config: DSMAccountInfo, presentingController: UIViewController) {
guard let documentURL = R.file.tgkCapitalPortfolioBAgreementPdf(),
let documentData = try? Data(contentsOf: documentURL) else { return }

let envelopDefinition = DSMEnvelopeDefinition()
envelopDefinition.envelopeName = "Some name"
envelopDefinition.emailSubject = "Please Sign Envelope on Document"
envelopDefinition.emailBlurb = "Hello, Please sign my Envelope"

let document = DSMDocument()
document.name = R.file.tgkCapitalPortfolioBAgreementPdf.name
document.documentId = "1"
document.documentBase64 = documentData.base64EncodedString()

envelopDefinition.documents = [document]

let signHere = DSMSignHere()
signHere.documentId = document.documentId
signHere.pageNumber = 1
signHere.recipientId = "1"
signHere.frame = .init(originX: 100,
originY: 100,
width: 100,
height: 100,
originYOffsetApplied: 50)
signHere.tabId = "1"

let tabs = DSMTabs()
tabs.signHereTabs = [signHere]

let signer = DSMSigner()
signer.email = config.email
signer.name = config.userName
signer.recipientId = "1"
signer.tabs = tabs

let signers: [DSMSigner] = [signer]

let recipients = DSMRecipients()
recipients.signers = signers

envelopDefinition.recipients = recipients
envelopDefinition.status = "created"

envelopesManager.composeEnvelope(with: envelopDefinition, signingMode: .offline) { [weak self] envelopID, error in
if let envelopID = envelopID {
print(envelopID)
self?.presentSigning(presenter: presentingController,
envelopeID: envelopID)
} else {
print(error.localizedDescription)
}
}
}
presentSigning方法也是:
private func presentSigning(presenter: UIViewController, envelopeID: String) {
envelopesManager.resumeSigningEnvelope(withPresenting: presenter,
envelopeId: envelopeID) { (viewController, error) in
if let viewController = viewController {
print(viewController)
}

if let error = error {
print(error.localizedDescription)
}
}
}
但是现在我在 presentSigning 中遇到了错误方法: Envelope is ready for sync and can not be resumed for signing.并且没有显示我的 pdf 文档的任何屏幕。如何解决?我如何预览此文档,然后添加用户签名的功能?
解决方案 EnvelopManager的工作代码类(class):
final class EnvelopeManager {

private let envelopesManager = DSMEnvelopesManager()
private let templateManager = DSMTemplatesManager()

// MARK: - Lifecycle

func sync() {
envelopesManager.syncEnvelopes()
}

func perform(with config: DSMAccountInfo, presentingController: UIViewController) {
guard let path = Bundle.main.path(forResource: R.file.tgkCapitalPortfolioBAgreementPdf.name, ofType: "pdf") else { return }

let envelopDefinition = DSMEnvelopeDefinition()
envelopDefinition.envelopeName = "Some name"
envelopDefinition.emailSubject = "Please Sign Envelope on Document"
envelopDefinition.emailBlurb = "Hello, Please sign my Envelope"

let builder = DSMDocumentBuilder()
builder.addDocumentId("1")
builder.addName(R.file.tgkCapitalPortfolioBAgreementPdf.name)
builder.addFilePath(Bundle.main.path(forResource: R.file.tgkCapitalPortfolioBAgreementPdf.name,
ofType: "pdf")!)
let document = builder.build()

envelopDefinition.documents = [document]

let signHere = DSMSignHere()
signHere.documentId = document.documentId
signHere.pageNumber = 1
signHere.recipientId = "1"
signHere.frame = .init(originX: 100,
originY: 100,
width: 100,
height: 100,
originYOffsetApplied: 50)
signHere.tabId = "1"

let tabs = DSMTabs()
tabs.signHereTabs = [signHere]

let signer = DSMSigner()
signer.email = config.email
signer.name = config.userName
signer.userId = config.userId
signer.clientUserId = config.userId
signer.routingOrder = 1
signer.recipientId = "1"
signer.tabs = tabs

let signers: [DSMSigner] = [signer]

let recipients = DSMRecipients()
recipients.signers = signers

envelopDefinition.recipients = recipients
envelopDefinition.status = "created"

envelopesManager.composeEnvelope(with: envelopDefinition, signingMode: .offline) { [weak self] envelopID, error in
if let envelopID = envelopID {
print(envelopID)
self?.presentSigning(presenter: presentingController,
envelopeID: envelopID)
} else {
print(error.localizedDescription)
}
}
}

private func presentSigning(presenter: UIViewController, envelopeID: String) {
envelopesManager.resumeSigningEnvelope(withPresenting: presenter,
envelopeId: envelopeID) { (viewController, error) in
if let viewController = viewController {
print(viewController)
}

if let error = error {
print(error.localizedDescription)
}
}
}
}
在您签署文件后,不要忘记调用 sync顶 View Controller 上的方法

最佳答案

但是现在我在 presentSigning 方法中遇到了错误:信封已准备好进行同步,无法恢复进行签名。Envelope is ready for sync and can not be resumed for signing.表示信封没有等待签名的本地签名者的状态。这可能由于几个原因而发生。
查看 guide 的添加收件人部分,这会向本地信封添加远程签名者。

// Create an envelope recipient with name and email and assign an id and type with routing order
DSMEnvelopeRecipient *recipient = [[[[[[DSMRecipientBuilder builderForType: DSMRecipientTypeSigner]
addRecipientId: @"1"]
addSignerName: @"Jane Wood"]
addSignerEmail: @"JaneWood@docusign.com"]
addRoutingOrder: 1]
build];
没有添加本地签名者来捕获签名。如果您需要添加本地签名者,他们可以代表以下情况:
  • SDK 验证帐户可用作签名者 ( DSMRecipientTypeSigner )。在示例中:@"JaneWood@docusign.com"使用 SDK 登录 routingOrder (或 SigningOrder) of 1 .
  • SDK 身份验证帐户可用作亲自签名者 ( DSMRecipientTypeInPersonSigner ) 的主机。以下示例将为 @"JaneWood@docusign.com" 添加亲自签名者作为主持人:
  • // Create an envelope recipient with name and email and assign an id and type with routing order
    DSMEnvelopeRecipient *recipient = [[[[[[[DSMRecipientBuilder builderForType: DSMRecipientTypeInPersonSigner]
    addRecipientId: @"1"]
    addHostName: @"Jane Wood"]
    addHostEmail: @"JaneWood@docusign.com"]
    addSignerName: @"IPS - John Local Doe"]
    addRoutingOrder: 1]
    build];
  • 仅将远程签名者(非本地 SDK 帐户)添加到信封:调用 syncEnvelopes在此类信封上将发送文件并通过电子邮件发送远程签名者以完成签名。

  • 注:所有本地签名者都已完成签名:一旦所有本地签名都被捕获,您将使用 syncEnvelopes 到达此案例。将信封发送到 DocuSign 服务器。

    关于ios - 无法使用在线签名模式创建信封,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66969169/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com