https://github.com/yonat/easybackgroundrefresh
Easy background refresh registration, scheduling, execution, and completion. BGTaskScheduler for the lazy.
https://github.com/yonat/easybackgroundrefresh
background-fetch background-refresh ios swift
Last synced: about 1 year ago
JSON representation
Easy background refresh registration, scheduling, execution, and completion. BGTaskScheduler for the lazy.
- Host: GitHub
- URL: https://github.com/yonat/easybackgroundrefresh
- Owner: yonat
- License: mit
- Created: 2022-08-16T05:17:23.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-01T14:07:49.000Z (over 1 year ago)
- Last Synced: 2025-04-18T11:24:47.216Z (about 1 year ago)
- Topics: background-fetch, background-refresh, ios, swift
- Language: Swift
- Homepage:
- Size: 25.4 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# EasyBackgroundRefresh
Easy background refresh registration, scheduling, execution, and completion.
`BGTaskScheduler` for the lazy.
[![Swift Version][swift-image]][swift-url]
[![License][license-image]][license-url]
[](https://img.shields.io/cocoapods/v/EasyBackgroundRefresh.svg)
[](http://cocoapods.org/pods/EasyBackgroundRefresh)
[](http://makeapullrequest.com)
## Usage
For fast refreshes:
```swift
struct MyApp: App {
let backgroundRefresh = EasyBackgroundRefresh(autoCompleteDelay: 3) { _ in
// quickly refresh your data in less than autoCompleteDelay seconds
}
...
}
```
For longer refreshes:
```swift
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](https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app).
By default, EasyBackgroundRefresh uses your app Bundle ID as the background task ID. You can change that by passing a different value to init:
```swift
let backgroundRefresh = EasyBackgroundRefresh(taskIdentifier: "io.another.identifier")
```
## Installation
### CocoaPods:
```ruby
pod 'EasyBackgroundRefresh'
```
### Swift Package Manager:
```swift
dependencies: [
.package(url: "https://github.com/yonat/EasyBackgroundRefresh", from: "1.0.5")
]
```
[swift-image]:https://img.shields.io/badge/swift-5.0-orange.svg
[swift-url]: https://swift.org/
[license-image]: https://img.shields.io/badge/License-MIT-blue.svg
[license-url]: LICENSE.txt