Skip to content

Reader Settings

ReaderSettings

To create the settings for the Reader you need to use the ReaderSettings class. The initializer accepts 5 parameters. The docTypeIndex which is an integer (default value for all document type is -1), the requestMode which can be all, age and contact (see below the RequestMode object), the requestIdentifyingInfo (whether to request identifying information), the enableOnline (to enable online retrieval) and the licenseData which is your license file converted in Data object

struct ReaderSettings {

    /// Initializer
    public init(docTypeIndex: Int, requestMode: MValidSdk.RequestMode, requestIdentifyingInfo: Bool, enableOnline: Bool, licenseData: Data)

    /// To request all supported doc types use value -1
    public var docTypeIndex: Int

    /// request mode (age, contact, all)
    public var requestMode: MValidSdk.RequestMode

    /// Whether to request identifying information (names etc.)
    public var requestIdentifyingInfo: Bool

    /// Enable online retrieval?
    public var enableOnline: Bool

    /// License data
    ///
    /// If you dont pass a valid license, the program will stop immediately
    public var licenseData: Data

    /// Custom field values to request for a set of doc. types and namespaces
    ///
    /// Overrides ``docTypeIndex``, ``requestMode``, ``requestIdentifyingInfo``
    public var customFields: [String : [String : [String]]]?
}

RequestMode

The RequestMode has 3 different types of request: age, contact, all.

enum RequestMode {
    case all
    case age
    case contact
}

Finally, you can initialize the ReaderSettings with all the neccessary data you want to use:

let licenseUrl = Bundle.main.url(forResource: "license", withExtension: "skm")!
let licenseData = try! Data(contentsOf: licenseUrl)
let settings = ReaderSettings(docTypeIndex: 0, requestMode: .age, requestIdentifyingInfo: false, enableOnline: true, licenseData: licenseData)