Native iOS

Implement logging and error handling for Fordefi's Native iOS SDK.

Add logging

To receive logs from the SDK, you can create your own class implementing the interface IFordefiLogger, and call the method setLogger with an instance of this class.

import FordefiSdk

class ViewController: UIViewController {
    private var fordefi: Fordefi?
    override func viewDidAppear(_ animated: Bool) {
        ///...
        self.fordefi!.setLogger(logger: MyFordefiLogger())
    }
}

class MyFordefiLogger: IFordefiLogger {
    func logLevel() -> FordefiLogLevel {
        return FordefiLogLevel.verbose
    }

    func log(logLevel: FordefiLogLevel, message: String) {
        print("FordefiSDK \(logLevel.rawValue) : \(message)")
    }
}

Add error handling

To receive error reports from the Fordefi SDK, you can create your own class implementing interface IFordefiErrorHandler, and call method setErrorHandler with an instance of this class.

import FordefiSdk

class ViewController: UIViewController {
    private var fordefi: Fordefi?
    override func viewDidAppear(_ animated: Bool) {
        ///...
        self.fordefi!.setErrorHandler(errorHandler: MyErrorHandler())
    }
}

class MyErrorHandler: IFordefiErrorHandler {
    func handleError(_ error: FordefiError) {
        print("FordefiSDK Error: \(error.errorDescription!)")
    }
}