Skip to content

Database

How to add, update, and remove the database.

Overview

A database is a db.dat file that contains the documents' data. It's mandatory to have the db.dat file if the document type and Visual zone data should be recognized. If MRZ, Barcode recognition or image cropping is performed, there is no need to have the database inside the application.

Warning

If you have the database in the app and want to add a new version, do not forget to increase the app's version first.

Add Database

Manually

Info

This option is the only option for applications that need to work offline.

Go to licensing.regulaforensics.com and select the "Databases" page. Download the database provided there and add it to the required project's target.

Once you build and run the project, the database will be located inside the application and processed by the SDK.

Use prepareDatabase Method

Warning

Make sure to have a stable Internet connection as the database is downloaded from our server.

Info

This method downloads the new version of the database only if the current one is incompatible with the SDK.

#1

DocReader.shared.prepareDatabase(databaseID: "Full", progressHandler: { (progress) in
    print(progressValue) // progress block
}, completion: { (success, error) in
    if success {
        print(success) // Success state
    } else {
        print(error) // Error status
    }
})
[RGLDocReader.shared prepareDatabase:@"Full" progressHandler:^(NSProgress * _Nonnull progress) {
    // progress block
} completion:^(BOOL success, NSError * _Nullable error) {
    if (success) {
        NSLog(success ? @"YES" : @"NO"); // Success state
    } else {
        NSLog(@"%@", error); // Error status
    }
}];

#2

DocReader.shared.prepareDatabase(databaseID: "Full") { (success, error) in
    if success {
        print(success) // Success state
    } else {
        print(error) // Error status
    }
}
[RGLDocReader.shared prepareDatabase:@"Full" completion:^(BOOL success, NSError * _Nullable error) {
    if (success) {
        NSLog(success ? @"YES" : @"NO"); // Success state
    } else {
        NSLog(@"%@", error); // Error status
    }
}];

If the operation is completed successfully, the database is added to the resources of the application.

If the existing database isn't compatible with the SDK or there is no database in the app at all, the new version of the database is downloaded.

If the database was removed from the app, it is downloaded again as soon as this function is invoked.

Use runAutoUpdate Method

Warning

Make sure to have a stable Internet connection as the database is downloaded from our server.

Info

This method downloads the newest version of the database that it finds on our server even if your current database is still compatible with the SDK. If there are no updates to the database, nothing is downloaded.

#1

DocReader.shared.runAutoUpdate(databaseID: "Full", progressHandler: { (progress) in
    print(progressValue) // progress block
}, completion: { (success, error) in
    if success {
        print(success) // Success state
    } else {
        print(error) // Error status
    }
})
[RGLDocReader.shared runAutoUpdate:@"Full" progressHandler:^(NSProgress * _Nonnull progress) {
    // progress block
} completion:^(BOOL success, NSError * _Nullable error) {
    if (success) {
        NSLog(success ? @"YES" : @"NO"); // Success state
    } else {
        NSLog(@"%@", error); // Error status
    }
}];

#2

DocReader.shared.runAutoUpdate(databaseID: "Full") { (success, error) in
    if success {
        print(success) // Success state
    } else {
        print(error) // Error status
    }
}
[RGLDocReader.shared runAutoUpdate:@"Full" completion:^(BOOL success, NSError * _Nullable error) {
    if (success) {
        NSLog(success ? @"YES" : @"NO"); // Success state
    } else {
        NSLog(@"%@", error); // Error status
    }
}];

Info

"Full" is the ID of the database to be downloaded.

If the operation is completed successfully, the database is added to the resources of the application.

If the existing database isn't compatible with the SDK or there is no database in the app at all, the freshest version of the database is downloaded.

Remove Database

To remove the added database, invoke:

DocReader.shared.removeDatabase { (success, error) in
    if success {
        print(success) // Success state
    } else {
        print(error) // Error status
    }
}
[RGLDocReader.shared removeDatabase:^(BOOL success, NSError * _Nullable error) {
    if (success) {
        NSLog(success ? @"YES" : @"NO"); // Success state
    } else {
        NSLog(@"%@", error); // Error status
    }
}];

Cancel Database Update

To cancel the database update, invoke:

DocReader.shared.cancelDBUpdate()
[RGLDocReader.shared cancelDBUpdate];

FAQ

I don't need a database that includes all documents of the world. Is it possible to create a custom database with only certain documents?

Sure. Please reach out to us at support@regulaforensics.com and let us know which documents of which countries you need. We will create a custom database especially for you.

What is the difference between the prepareDatabase and runAutoUpdate methods?

The prepareDatabase method downloads the new version of the database only if the current one is incompatible with the SDK.

The runAutoUpdate method downloads the newest database version that it finds on our server even if the current database is still compatible with the SDK.

Which option should I use if my application needs to work offline?

The only option you can use in this case is the Manual one.

When should I invoke a method that adds the database to the app?

Before the initialization process is started.

Which option should I use so the app's package size is not increased?

Choose either the prepareDatabase or runAutoUpdate method.

Back to top