background-fetch icon indicating copy to clipboard operation
background-fetch copied to clipboard

option to defer until NetworkInformation type change

Open jimmywarting opened this issue 1 year ago • 1 comments

imagine a senario that you need to download or upload large data. you don't want users to use up all mobile data. so the solution would be to only do it when using wifi or ethernet network.

The solution i would wish for would be something like setting a connectionType for when the request should be initiated on:

/*
ConnectionType =
  | 'bluetooth'
  | 'cellular'
  | 'ethernet'
  | 'mixed'
  | 'none'
  | 'other'
  | 'unknown'
  | 'wifi'
  | 'wimax';
*/

const request = new Request('/upload', { body, method: 'POST' })

swReg.backgroundFetch.fetch(id, request, {
  // possible types: http://wicg.github.io/netinfo/#connection-types
  connectionType: ['wifi', 'ethernet']
})

jimmywarting avatar Jan 04 '24 22:01 jimmywarting