EasyBackgroundRefresh 1.0.3

EasyBackgroundRefresh 1.0.3

Maintained by Yonat Sharon.



  • By
  • Yonat Sharon

EasyBackgroundRefresh

Easy background refresh registration, scheduling, execution, and completion. BGTaskScheduler for the lazy.

Swift Version License CocoaPods Compatible Platform PRs Welcome

Usage

For fast refreshes:

struct MyApp: App {

    let backgroundRefresh = EasyBackgroundRefresh(autoCompleteDelay: 3) { _ in
        // quickly refresh your data in less than autoCompleteDelay seconds
    }
    
    ...
}

For longer refreshes:

struct MyApp: App {

    let backgroundRefresh = EasyBackgroundRefresh { backgroundRefresh in
        backgroundRefresh.isProcessing = true
        defer { backgroundRefresh.isProcessing = false }
        // refresh your data, take up to 30 seconds
    }
    
    ...
}

Note:

Remember to enable background refresh and add Info.plist keys as described in Apple docs.

By default, EasyBackgroundRefresh uses your app Bundle ID as the background task ID. You can change that by passing a different value to init:

let backgroundRefresh = EasyBackgroundRefresh(taskIdentifier: "io.another.identifier")

Installation

CocoaPods:

pod 'EasyBackgroundRefresh'

Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/yonat/EasyBackgroundRefresh", from: "1.0.1")
]