native-ios-sdk
native-ios-sdk copied to clipboard
Unable to Start Embedded Signature. Blank Screen + ProgressView.
Hi, good morning! I need some help with the embedded signature. I am using Swift, XCode 15.4, simulator with iOS 17.5. I am creating the envelope with the API:
EnvelopesAPI.envelopesPostEnvelopes(accountId:body:)
but them I am unable to start the embedded signature with:
DSMEnvelopesManager().presentCaptiveSigning(withPresenting:envelopeId:recipientUserName:recipientEmail:recipientClientUserId:animated:)
After calling the method above, just a blank screen and a ProgressView appear, nothing else. I enabled logs on DocuSign platform and after going through them (in attachments) I noticed that the below call:
POST https://demo.docusign.net/restapi/v2.1/accounts/<account-id>/envelopes/<envelope-id>/views/recipient
fails with error:
{"errorCode":"UNKNOWN_ENVELOPE_RECIPIENT","message":"The recipient you have identified is not a valid recipient of the specified envelope."}
I already added an extra call to verify the created recipients before starting the embedded signature but still, I couldn't identify any reason on why the recipient would not be válid. In the attached logs, there's also the result for the extra call getting all the receipients for the envelope.
I am using the below code and call sequence:
1) Start DocuSign Session:
let userSession = try await DSMManager.login(
withAccessToken: accessToken, // Get this from backend. Same is used for Android and it works fine.
accountId: apiAccountId, // ********-****-****-****-************ double checked.
userId: userAccountId, // ********-****-****-****-************ double checked.
userName: userAccountName, // 4FreedomHub Developer "Directly from DocuSign platform"
email: userAccountEmail, // developer.********.***@4freedomhub.com "Directly from DocuSign platform"
host: URL(string: baseURI)!, // https://demo.docusign.net/restapi
integratorKey: integrationKey, // ********-****-****-****-************
refreshToken: refreshToken, // nil
expiresIn: Date(timeIntervalSinceNow: TimeInterval(expireIn)) // Get this from backend
)
After this call, no error happens but I noticed that inside userSession
object, accountId
is empty and if I try to use userSession.host
the SDK crash. For this reason, I am unable to directly use userSession.host
neither userSession.accountId
in the creation of the envelope but I am sending the exact same values. THIS IS THE FIRST PROBLEM I BELIEVE I NEED A FIX FOR.
2) Composing Envelope:
let recipientPermuted = DSAPIInPersonSigner(
clientUserId: recipientUserId, // 2SIVn1ybGDQOBNQtJyLX9qhgpxn1
hostEmail: userSession.email, // developer.********.***@4freedomhub.com
hostName: userSession.accountName, // 4FreedomHub Developer
recipientId: "1",
routingOrder: "1"
signerEmail: recipientEmail, // signer.test.****.********@4freedomhub.com
signerName: recipientName, // Jonathan Santos
status: "SENT",
tabs: DSAPITabs(
signHereTabs:[DSAPISignHere(
anchorCaseSensitive: false,
anchorString: signatureAnchor, // "{{permuted_authentication}}"
documentId: "1",
pageNumber: "1",
recipientId: "1"
)]
)
)
let recipientPermuting = ...
let recipientAuthorizer = ...
let pdfData = try Data(contentsOf: permutationFile)
let document = DSAPIDocument()
document.documentId = documentId
document.documentBase64 = pdfData.base64EncodedString()
document.name = permutationFile.deletingPathExtension().lastPathComponent
document.fileExtension = "pdf"
let apiEnvelope = DSAPIEnvelopeDefinition(
documents: [document],
emailSubject: envelopeSubject, // "Permuta de Horário de Serviço"
recipients: DSAPIRecipients(
inPersonSigners: [recipientPermuted, recipientPermuting, recipientAuthorizer]
),
signerCanSignOnMobile: true,
status: "SENT"
)
DSClientAPI(
basePath: baseURI,
customHeaders: ["Authorization": "Bearer \(hostAccountInfo.accessToken)"]
)
EnvelopesAPI.envelopesPostEnvelopes(
accountId: apiAccountId, // ********-****-****-****-************
body: apiEnvelope
) { [weak self] envelopeSummary, error in
if let error = error {
...
return
}
if let errorDetails = envelopeSummary?.errorDetails {
...
return
}
guard let envelopeId = envelopeSummary?.envelopeId else {
...
return
}
// envelopeId of created envelope. 786b3e9b-9b8a-4219-b4b1-a577824893a4
}
3) Trying to start the Embedded signature flow
guard let rootViewController = await getRootViewController() else {
...
return
}
DSMEnvelopesManager().presentCaptiveSigning(
withPresenting: rootViewController,
envelopeId: envelopeId, // 786b3e9b-9b8a-4219-b4b1-a577824893a4
recipientUserName: recipientUserName, // Jonathan Santos
recipientEmail: recipientEmail, // signer.test.****.********@4freedomhub.com
recipientClientUserId: recipientClientUserId, // 2SIVn1ybGDQOBNQtJyLX9qhgpxn1
animated: true
)
As I mentioned, I already added an extra call before starting the Embedded Signature flow, retrieving all recipients for the created envelope, no errors were found and I used the exact data received from this call (which is the same I am sending anyways) to start the signature flow but the error persists (blank screen and ProgressView. Nothing else).
I also noticed that if, for the presentCaptiveSigning
call, I swap the recipientUserName
and recipientEmail
and send the HOST name and HOST email instead, the inicial screen for the signature flow appears but it appears behind the ProgressView which is not dismissed neither I found a way to dismiss it.
It was just an experiment but I have doule checked the host values and signer values on both the envelope creation and from the get recipients call before the signature.
DOCUSIGN_LOGS_06-09-FILTERED.zip