Use custom redaction
Some countries and jurisdictions require that specific fields in identity documents be redacted before any data leaves the device. BlinkID ships with several built-in redaction rules that automatically cover some of these requirements for certain document classes.
Default redaction
Default redaction applies automatically. When a scan completes, the SDK looks up its built-in rules for the scanned document class and applies them to the result before returning it. For example, German ID cards have their document number redacted by default.
No action is needed to perform default redaction.
Custom redaction
You can perform your own custom redactions.
You can either override the redactions if they do not apply to your legal requirements, or add your redactions on top of the default ones.
Override redactions
To override default redactions, return a RedactionSettings object with the fields you want to resolve from your resolver.
The SDK removes the default redactions, and applies yours.
Return null (web, Android) or nil (iOS) for all other documents to keep their defaults unchanged.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
const blinkId = await createBlinkId({
licenseKey: "...",
redactionSettingsResolver: (classInfo) => {
if (classInfo.country?.id === "germany" && classInfo.documentType?.id === "id") {
return { fields: ["sex", "dateOfBirth"] };
}
return null; // use SDK defaults for all other documents
},
});
@Parcelize
class MyRedactionResolver : RedactionSettingsResolver {
override fun resolveRedactionSettings(classInfo: DocumentClassInfo): RedactionSettings? {
if (classInfo.country?.id == CountryId.Germany && classInfo.documentType?.id == DocumentTypeId.Id) {
return RedactionSettings(
fields = listOf(FieldType.Sex, FieldType.DateOfBirth),
documentNumberRedactionSettings = null
)
}
return null // use SDK defaults for all other documents
}
}
BlinkIdCameraScanningScreen(
blinkIdSdk = blinkIdSdk,
uxSettings = BlinkIdUxSettings(
redactionSettingsResolver = MyRedactionResolver()
),
onScanningSuccess = { result -> },
onScanningCanceled = { }
)
struct MyRedactionResolver: RedactionSettingsResolver {
func resolveRedactionSettings(classInfo: DocumentClassInfo) -> RedactionSettings? {
if classInfo.country?.countryId == .germany, classInfo.documentType?.documentTypeId == .id {
return RedactionSettings(fields: [.sex, .dateOfBirth])
}
return nil // use SDK defaults for all other documents
}
}
let analyzer = try await BlinkIDAnalyzer(
sdk: sdk,
redactionSettingsResolver: MyRedactionResolver()
)
Add custom redactions to default ones
To extend the default redactions with additional fields, retrieve the defaults for the scanned document class inside your resolver and add your fields to the result.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
const blinkId = await createBlinkId({
licenseKey: "...",
redactionSettingsResolver: async (classInfo) => {
const defaults = await blinkId.blinkIdCore.getDefaultRedactionSettings(classInfo);
return {
...defaults,
fields: [...defaults.fields, "sex", "dateOfBirth"],
};
},
});
@Parcelize
class MyRedactionResolver : RedactionSettingsResolver {
override fun resolveRedactionSettings(classInfo: DocumentClassInfo): RedactionSettings? {
val defaults = RedactionSettings.getDefaultRedactionSettings(classInfo)
return defaults.copy(
fields = defaults.fields + listOf(FieldType.Sex, FieldType.DateOfBirth)
)
}
}
struct MyRedactionResolver: RedactionSettingsResolver {
func resolveRedactionSettings(classInfo: DocumentClassInfo) -> RedactionSettings? {
guard var settings = RedactionSettings.getDefaultRedactionSettings(for: classInfo) else {
return nil
}
settings.fields += [.sex, .dateOfBirth]
return settings
}
}
let analyzer = try await BlinkIDAnalyzer(
sdk: sdk,
redactionSettingsResolver: MyRedactionResolver()
)
Remove redactions
To disable redaction entirely, return a RedactionSettings object with mode set to "none" from your resolver for every document class.
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
const blinkId = await createBlinkId({
licenseKey: "...",
redactionSettingsResolver: () => ({ mode: "none", fields: [] }),
});
@Parcelize
class NoRedactionResolver : RedactionSettingsResolver {
override fun resolveRedactionSettings(classInfo: DocumentClassInfo): RedactionSettings? {
return RedactionSettings(
redactionMode = RedactionMode.None,
fields = emptyList(),
documentNumberRedactionSettings = null
)
}
}
struct NoRedactionResolver: RedactionSettingsResolver {
func resolveRedactionSettings(classInfo: DocumentClassInfo) -> RedactionSettings? {
return RedactionSettings(mode: .none, fields: [])
}
}
let analyzer = try await BlinkIDAnalyzer(
sdk: sdk,
redactionSettingsResolver: NoRedactionResolver()
)
MRZ and barcode redactions
In addition to redactions which use mode and fields, you can also use two additional flags: redactMrz and redactBarcode (boolean).
These redact the data extracted from the MRZ or barcode.
Note that this redaction doesn't propagate to the top result.
For example, if a piece of information is present both in the visual zone and the machine-readable zone, and you redact the machine-readable zone, this information will still be present in the result (unless also covered by a field in the fields array).
- Web (TS)
- Android (Kotlin)
- iOS (Swift)
const blinkId = await createBlinkId({
licenseKey: "...",
redactionSettingsResolver: () => ({ fields: [], redactMrz: true, redactBarcode: true }),
});
@Parcelize
class MyRedactionResolver : RedactionSettingsResolver {
override fun resolveRedactionSettings(classInfo: DocumentClassInfo): RedactionSettings? {
return RedactionSettings(
fields = emptyList(),
documentNumberRedactionSettings = null,
redactMrz = true,
redactBarcode = true
)
}
}
struct MyRedactionResolver: RedactionSettingsResolver {
func resolveRedactionSettings(classInfo: DocumentClassInfo) -> RedactionSettings? {
return RedactionSettings(fields: [], redactMrz: true, redactBarcode: true)
}
}
let analyzer = try await BlinkIDAnalyzer(
sdk: sdk,
redactionSettingsResolver: MyRedactionResolver()
)