Flutter — Setup¶
Installation¶
flutter pub add background_fetch
iOS Setup¶
CocoaPods¶
If you're not using Swift Package Manager, adjust use_frameworks! in your ios/Podfile:
target 'Runner' do
use_frameworks! :linkage => :static # <-- append :linkage => :static
end
Warning
Without :linkage => :static, you'll get a build error about statically linked binaries in the TSBackgroundFetch.xcframework.
Background Modes¶
In Xcode, select your project root → Signing & Capabilities → + Capability → Background Modes. Enable:
- [x] Background fetch
- [x] Background processing (only if you intend to use
BackgroundFetch.scheduleTask)

Info.plist¶
Open your Info.plist and add the key "Permitted background task scheduler identifiers":

Add the required identifier com.transistorsoft.fetch:

If you intend to execute your own custom tasks via BackgroundFetch.scheduleTask, you must add those custom identifiers as well. For example, if you intend to execute a custom taskId: 'com.transistorsoft.customtask', you must add the identifier com.transistorsoft.customtask to your "Permitted background task scheduler identifiers", as well.
Warning
A task identifier can be any string you wish, but it must be prefixed with com.transistorsoft..
Android Setup¶
No additional Android setup is required for background_fetch >= 1.5.0.
Upgrading from < 1.5.0?
If you previously added a custom maven URL for background_fetch in your android/build.gradle, you can now remove it.