Your app can receive an OOB request either by scanning a QR code or by receiving a push notification. This section describes how this processing can be customized.
Customizing push notification processing
You can customize the processing of the OOB authentication which is triggered when your app receives a push notification. Instead of calling OOBSDK.didReceiveOOBPushNotification(userInfo), as described in Enabling Push Notifications, use the code block below which includes a critical call to processOOB(). The processOOB() method performs the actual OOB authentication. Place your customizations before and/or after this call.
Do not perform this call from a UI thread because the call executes synchronously and blocks the calling thread. If an error occurs during the processOOB call, an exception is thrown. Put the call in a try block.
//Get authData from notification.
DispatchQueue.global(qos: .background).async {
do {
try NNLAppSDKPlus.tryAndCatch {
let authData:AuthenticationData! = self.oobsdk.processOOB(code,
withExtras:nil)
}
}
catch {
//convert to NSError to check the status code
let err:NSError = error as NSError
}
}Execute this code block in the following places:
AppDelegate’s didFinishLaunchingWithOptions()
If launchOptions is not nil, execute the code block.AppDelegate’s didReceiveRemoteNotification()
Customizing QR code processing
By default, the App SDK displays an alert with the FIDO operation's completion status. You can customize the processing of the OOB registration or authentication by doing the following:
Create a QRScannerViewDelegate instance and assign it to the
QRScannerView.delegate property.Implement a callback called
QRScannerViewDelegate::scannerView(_ scannerView:QRScannerView!, didReadCode code:String!)
This is called when a QR code is scanned. In the body of this method, you must call OOBSDK.processOOB() to perform the OOB registration or authentication operation based on the scanned QR code. Put the call in a try block. Do not perform this call from a UI thread because the call executes synchronously and blocks the calling thread. If any error happens during processOOB(), an AppSDKPlusException is thrown. Implement your changes around the call to OOBSDK.processOOB().
Working Example in Tutorial App
Refer to file QRCodeScanViewController.swift.
Customizing QR code scanner messages
You can customize the informational messages that are displayed when the camera that is used to scan a QR code turns on or off.
Use the ScannerStateDelegate to receive scanner on/off events. The OOB SDK also triggers this delegate when the device idles to reduce power consumption.
Create a ScannerStateDelegate instance and assign it to the QRScannerView.stateDelegate property.
ScannerStateDelegate.scannerDidSwitchOff() is called when the camera is switched off after idle detection.
ScannerStateDelegate.scannerDidSwitchOn() is called when the camera is switched on after being in an idle state.