Skip to main content

Auto-Scrape

The automated e-receipt scrape is a host-controlled permission gate plus a periodic background scrape of the user's linked Gmail IMAP accounts. Once the host opts the user in, the SDK schedules a periodic WorkManager job that runs the same scrape as ImapClient.messages(...) over every eligible linked account and delivers the results through a callback.

The gate is off by default and lives in memory only — persist the user's choice in your app and re-apply it at launch (for example in Application.onCreate()), before any scheduled run fires.

Package: com.microblink.digital

Declaration

class BlinkReceiptDigitalSdk

Auto-scrape is configured through the BlinkReceiptDigitalSdk facade. The application context is resolved from the SDK, so these methods take no Context.


Quick Reference

Methods

MethodDescription
autoScrapeEnabled(enabled)The permission gate; schedules or cancels the periodic scrape
autoScrapeEnabled()Returns whether auto-scrape is currently enabled
autoScrapeInterval(hours)Sets the scrape cadence in hours (stored only)
autoScrapeInterval(hours, apply)Sets the cadence and optionally reschedules immediately
autoScrapeInterval()Returns the current cadence in hours
autoScrapeCallback(callback)Registers a per-account results callback

Methods

autoScrapeEnabled(enabled)

fun autoScrapeEnabled(enabled: Boolean)

The permission gate. true authorizes automatic scraping and schedules the periodic work; false cancels any pending run. Off by default. Call after the SDK has initialized.


autoScrapeEnabled()

fun autoScrapeEnabled(): Boolean

Returns whether auto-scrape is currently enabled.


autoScrapeInterval(hours)

fun autoScrapeInterval(hours: Int)

Sets the scrape cadence in hours. Clamped to the 12–36 hour window; a non-positive value resets to the 24 hour default. Stored only — the new cadence applies the next time auto-scrape is enabled from off.


autoScrapeInterval(hours, apply)

fun autoScrapeInterval(hours: Int, apply: Boolean)

Sets the cadence (clamped as above). When apply is true and auto-scrape is currently enabled, reschedules the background work so the change takes effect immediately; when false, behaves like the single-argument overload.


autoScrapeInterval()

fun autoScrapeInterval(): Int

Returns the current cadence in hours.


autoScrapeCallback(callback)

fun autoScrapeCallback(callback: MessagesCallback?)

Registers a per-account results callback for automated scrapes, invoked once per account on a background thread — the same shape as the manual ImapClient.messages(callback) path. Pass null to clear it.


Provider Scope

Automated scrapes currently cover Gmail IMAP accounts with a non-empty username only. Other linked providers (Yahoo, AOL, Outlook) are skipped by the background scrape; the manual ImapClient.messages(...) path is unaffected.


Requirements

  • The scrape runs under a WorkManager periodic job with a NetworkType.CONNECTED constraint and exponential backoff; WorkManager is initialized automatically and needs no manifest changes.
  • At least one eligible linked Gmail account must be present, otherwise a scheduled run completes as a no-op.

Note: the gate is not persisted by the SDK. Store the user's opt-in in your app and re-apply it at launch before any scheduled run fires.