Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Periodic Background Sync

Jxck
April 17, 2020

Periodic Background Sync

LT about periodic background sync at #remo_study

Jxck

April 17, 2020
Tweet

More Decks by Jxck

Other Decks in Technology

Transcript

  1. Periodic
    Background
    Sync
    Periodic
    Background
    Sync

    View Slide

  2. View Slide

  3. Background
    Sync
    self.on('sync', (e) => {
    // retry failed request while
    // offline in background
    })

    View Slide

  4. Periodic
    Background
    Sync
    self.on('periodic-sync', (e) => {
    // periodically refresh contents
    // up to date in background.
    })

    View Slide

  5. Use Case - Podcast
    Feed
    Update

    View Slide

  6. // register PBS
    const name = 'periodic-background-sync'
    const status = await navigator.permissions.query({name})
    if (status.state === 'granted') {
    await registration.periodicSync.register('refresh', {
    minInterval: 12 * 60 * 60 * 1000 // 12h
    })
    }

    View Slide

  7. Security Consideration

    View Slide

  8. #4: 156.74.xxx.xxx
    #1: 14.102.xxx.xxx
    #2: 81.177.xxx.xxx
    #3: 24.152.xxx.xxx
    Background Sync Tracking
    also
    ● crypto mining
    ● bot net

    View Slide

  9. Known Network

    View Slide

  10. Permission
    In Chrome

    View Slide

  11. Permission Model
    Permission Dialog ?
    User Gesture ?
    Feature Policy ?
    Add to Home Screen !!

    View Slide

  12. Native App Permission
    -> Install
    Web App Permission
    -> Install

    View Slide

  13. Restriction
    In Chrome

    View Slide

  14. ● Periodic depends on site-engagement.
    ● Only fire under known network.

    View Slide

  15. Site Engagement

    View Slide

  16. Periodic Background Sync enables...
    ● Installed App via A2HS
    ● Enough Site-Engagement
    ● Connected to Known Network
    ● Android Chrome only

    View Slide

  17. Work in progress...

    View Slide

  18. View Slide