搜尋套件、儲存庫與 APP 分類

套件詳情v1.7.0

background_fetch

支援 iOS 與 Android 的背景週期性回呼。包含 Android 的無頭實作。

AndroidiOS
近 30 天下載
12.3萬
喜歡數
1260
Pub 分數
155

安裝套件

flutter pub add background_fetch

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 插件,可在 Android 和 iOS 上實現週期性背景執行,讓應用程式即使在關閉狀態下也能執行同步資料或取得更新等任務。它支援 Android 的 Headless JS 模式以實現可靠的背景處理,並提供跨平台一致的回呼。專為需要可靠背景活動但不依賴平台特定解決方案的開發者設計。

適用情境

  • 背景數據同步
  • 週期性任務執行
  • 推送通知處理
  • 應用狀態維護
  • 位置追蹤
  • 離線資料更新

主要特色

  • 跨平台支援(Android 與 iOS)
  • Android 無頭實作
  • 可設定的背景間隔
  • 持續的背景執行
  • 事件驅動的回呼系統
  • 低電量與電源優化

適合對象

  • 需要定期背景更新的應用
  • 資料密集型應用
  • 離線優先的行動應用程式
  • 追蹤或監控服務
  • 背景任務自動化

使用建議

  • Android 需要背景權限
  • 可能影響電池壽命
  • iOS 後台執行受系統政策限制
  • 需要正確配置以支援無頭模式
  • 背景擷取可能會被作業系統限制
  • 需要在真實裝置上進行測試以確保可靠性

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Background Fetch for Flutter

background_fetch · pub package

By Transistor Software, creators of Flutter Background Geolocation


Background Fetch is a very simple plugin which attempts to awaken an app in the background about every 15 minutes, providing a short period of background running-time. This plugin will execute your provided callbackFn whenever a background-fetch event occurs.

There is no way to increase the rate which a fetch-event occurs and this plugin sets the rate to the most frequent possible — you will never receive an event faster than 15 minutes. The operating-system will automatically throttle the rate the background-fetch events occur based upon usage patterns. Eg: if user hasn't turned on their phone for a long period of time, fetch events will occur less frequently or if an iOS user disables background refresh they may not happen at all.

:new: Background Fetch now provides a scheduleTask method for scheduling arbitrary "one-shot" or periodic tasks.

iOS
  • There is no way to increase the rate which a fetch-event occurs and this plugin sets the rate to the most frequent possible — you will never receive an event faster than 15 minutes. The operating-system will automatically throttle the rate the background-fetch events occur based upon usage patterns. Eg: if user hasn't turned on their phone for a long period of time, fetch events will occur less frequently.
  • scheduleTask seems only to fire when the device is plugged into power.
  • :warning: When your app is terminated, iOS no longer fires events — There is no such thing as stopOnTerminate: false for iOS.
  • iOS can take days before Apple's machine-learning algorithm settles in and begins regularly firing events. Do not sit staring at your logs waiting for an event to fire. If your simulated events work, that's all you need to know that everything is correctly configured.
  • If the user doesn't open your iOS app for long periods of time, iOS will stop firing events.
Android
  • The Android plugin provides a Headless implementation allowing you to continue handling events even after app-termination.

Contents

Licence

The MIT License

Copyright (c) 2018 Chris Scott, Transistor Software <chris@transistorsoft.com> https://www.transistorsoft.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

所屬分類

原始碼儲存庫

使用此套件的專案