Skip to content

Latest commit

 

History

History
49 lines (40 loc) · 1.98 KB

File metadata and controls

49 lines (40 loc) · 1.98 KB

BackgroundFetchOptions

Namespace: SpawnDev.SpawnJS.JSObjects
Source: JSObjects/BackgroundFetchOptions.cs
MDN Reference: BackgroundFetchOptions on MDN

Used to customize the BackgroundFetchManager fetch progress dialog that the browser shows to the user. https://developer.mozilla.org/en-US/docs/Web/API/BackgroundFetchManager/fetch#options

Properties

Property Type Access Description
BackgroundFetchOptions class get/set Used to customize the BackgroundFetchManager fetch progress dialog that the browser shows to the user. https://developer.mozilla.org/en-US/docs/Web/API/BackgroundFetchManager/fetch#options
Icons IEnumerable<IconInfo>? get
DownloadTotal long? get

Examples

SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:

  • Properties and methods use PascalCase (e.g., readyState becomes ReadyState)
  • Events use ActionEvent with +=/-= (e.g., addEventListener("click", fn) becomes OnClick += handler)
  • Async methods return Task<T> instead of Promise<T>
  • Objects should be disposed with using statements
  • Access via JS.Get<BackgroundFetchOptions>(...) or constructor new BackgroundFetchOptions(...)
navigator.serviceWorker.ready.then(async (swReg) => {
  const bgFetch = await swReg.backgroundFetch.fetch(
    "my-fetch",
    ["/ep-5.mp3", "ep-5-artwork.jpg"],
    {
      title: "Episode 5: Interesting things.",
      icons: [
        {
          sizes: "300x300",
          src: "/ep-5-icon.png",
          type: "image/png",
          label: "Downloading a show",
        },
      ],
      downloadTotal: 60 * 1024 * 1024,
    },
  );
});

See full example on MDN