Manual QR Entry
SDK for Android
To show the Enter Code Manually button on the QR Scan dialog, the user must override the flag as follows.
<!-- default value -->
<string name="hypr_common_qr_fallback_enabled_override" translatable="false">FALSE</string>
<!-- example -->
<string name="hypr_common_qr_fallback_enabled_override" translatable="false">TRUE</string>
SDK for iOS
Follow these steps to implement QR Fallback.
Within the HYPRWrapper
add the following function:
func pairWithQRFallback(parentViewController: UIViewController, appName: String, pin: String, eventBlock: @escaping HYPRUserAgentEventResult) {
HYPRUserAgent.qrCode(forAppName: appName, pin: pin) { result, error in
if let err = error {
eventBlock(.failure, err)
return
}
if let qrDict = result, let qrString = qrDict["qrCode"] as? String, let dict = self.convertStringToDictionary(text: qrString) {
print("received qr dict: \(dict)")
self.pairMachineWithJSONContent(parentViewController: parentViewController, registrationPayload: dict, eventBlock: eventBlock)
} else {
eventBlock(.failure, HYPRError(HYPRError.userAgentInvalidWebAuthenticationQRCode))
}
}
}
Within the HYPRWrapperProtocol
add:
func pairWithQRFallback(parentViewController: UIViewController, appName: String, pin: String, eventBlock: @escaping HYPRUserAgentEventResult)
In the WebProfileViewController
:
Inside the pairWebMachineTapped
function, add another action that would look something like this:
pairWebMachineOptions.addAction(UIAlertAction(title: "Pair with QR Fallback", style: .default, handler: { _ in
self.pairWithQRFallback()
}))
You will also need to add the following function to your WebProfileViewController
class:
func pairWithQRFallback() {
// Create the alert controller
let alertController = UIAlertController(title: "Enter QR Fallback Information", message: "Please add app name and pin", preferredStyle: .alert)
// Add the first text field
alertController.addTextField { textField in
textField.placeholder = "App name"
}
// Add the second text field
alertController.addTextField { textField in
textField.placeholder = "Pin"
}
// Add an action (button)
let confirmAction = UIAlertAction(title: "OK", style: .default) { [weak alertController] _ in
// Retrieve the text from the first and second text field
let appName = alertController?.textFields?[0].text ?? ""
let pin = alertController?.textFields?[1].text ?? ""
// Do something with the text
print("App name: \(appName), Pin: \(pin)")
HYPRWrapper.shared.pairWithQRFallback(parentViewController: self, appName: appName, pin: pin) { result, error in
self.handlePairingFinished(error: error)
}
}
// Add a Cancel action
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
// Add actions to the alert controller
alertController.addAction(confirmAction)
alertController.addAction(cancelAction)
// Present the alert
present(alertController, animated: true, completion: nil)
}