Sign Cross-Device Session

After a cross-device session is successfully created, and sent to and fetched from another device, you can proceed with document signing.

Check the cross-device session’s type property to make sure it is configured for signing. Note that sessions intended for signing are created with the signingHash property passed to the createCrossDeviceSession method.

To sign a document with the cross-device session, use the signCrossDeviceSession method for Android, iOS or Flutter.

miraclTrust.signCrossDeviceSession(
    crossDeviceSession = crossDeviceSession,
    user = user,
    pinProvider = pinProvider,
    resultHandler = ResultHandler { result ->
        when (result) {
            is MIRACLSuccess -> {
                // The cross-device session is signed.
            }

            is MIRACLError -> {
                // The cross-device session is not signed.
            }
        }
    }
)
val result = miraclTrust.signCrossDeviceSession(
    crossDeviceSession = crossDeviceSession,
    user = user,
    pinProvider = pinProvider
)

when (result) {
    is MIRACLSuccess -> {
        // The cross-device session is signed.
    }

    is MIRACLError -> {
        // The cross-device session is not signed.
    }
}
miraclTrust.signCrossDeviceSession(
    crossDeviceSession,
    user,
    pinProvider,
    result -> {
        if (result instanceof MIRACLSuccess) {
            // The cross-device session is signed.
        } else {
            // The cross-device session is not signed.
        }
    }
);
MIRACLTrust
    .getInstance()
    .signCrossDeviceSession(
        crossDeviceSession,
        user: user
    ) { processPinHandler in
        // Here the user provides their current User ID's PIN code.
        pinProcessor(<#Provide your PIN here#>)
    } completionHandler: { isSigned, error in
        // Handle your signing result here.
    }
[[MIRACLTrust getInstance]
        signCrossDeviceSession:crossDeviceSession
                          user:user
    didRequestSigningPinHandler:
                      ^(void (^ _Nonnull pinProcessor)(NSString * _Nullable)
    ) {
        // Here the user provides their current User ID's PIN code.
        pinProcessor(<#Provide your PIN here#>)
    } completionHandler:^(BOOL isSigned, NSError * _Nullable error) {
        // Handle your signing result here.
    }];

Promise:

try {
  await mcl.signCrossDeviceSession(crossDeviceSession, userId, userPin);
} catch (err) {
  // Handle any potential errors
}

Callback:

mcl.signCrossDeviceSession(crossDeviceSession, userId, userPin, function (err) {
  if (err) {
    // Handle any potential errors
  }
});
try {
  await miraclTrust.signCrossDeviceSession(crossDeviceSession, user, pin);
  // The cross-device session is signed.
} on SigningException catch(e) {
  // Handle the exception here.
}