Introduction
Flutter mobile development often requires periodic updates or server-driven tasks even when the app isn’t in the foreground. On iOS, you can leverage Background Fetch and Silent Push Notifications to run Dart code in background. This tutorial shows you how to configure Xcode, register handlers in Flutter, and test on real devices.
Configuring iOS Capabilities
Before any background work can start, enable the correct modes in Xcode:
Open Runner.xcworkspace in Xcode.
Select the Runner target, go to the “Signing & Capabilities” tab.
Click “+ Capability” and add Background Modes.
Under Background Modes, check Background fetch and Remote notifications.
Ensure your Info.plist includes:
UIBackgroundModes fetch remote-notification
This grants the OS permission to launch your app in response to fetch intervals or silent pushes.
Implementing Background Fetch in Flutter
Use the background_fetch plugin to schedule periodic callbacks in Dart. Add to pubspec.yaml:
dependencies: background_fetch: ^1.0.0
Then register a headless task and initialize the plugin in main.dart:
import 'package:background_fetch/background_fetch.dart';
void backgroundFetchHeadlessTask(HeadlessTask task) async {
final result = await fetchLatestServerData();
BackgroundFetch.finish(task.taskId);
}
void main() {
WidgetsFlutterBinding.ensureInitialized();
BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask);
runApp(MyApp());
}Next, configure fetch settings in your app’s init:
BackgroundFetch.configure(
BackgroundFetchConfig(
minimumFetchInterval: 15,
stopOnTerminate: false,
enableHeadless: true,
requiresBatteryNotLow: true,
), (String taskId) async {
await backgroundFetchHeadlessTask(HeadlessTask(taskId: taskId));
}, (String taskId) async {
BackgroundFetch.finish(taskId);
}
);The system invokes your callback roughly every 15 minutes depending on device conditions.
Setting Up Silent Push Notifications
Silent pushes arrive via APNs with no UI alert. They wake your app in background using the remote-notification mode.
In Apple Developer portal, enable Background Modes for your App ID, selecting Remote notifications.
Generate a push certificate or key for APNs and upload it to your push provider.
Add firebase_messaging to pubspec.yaml if you use FCM:
dependencies: firebase_messaging: ^14.0.0
In Xcode, ensure the Push Notifications capability is also enabled.
In your server payload, set content-available to 1 and omit alert, sound, badge:
{
"aps": {
"content-available": 1
},
"customData": { ... }
}
This tells iOS to wake your app silently and hand off the payload.
Handling Silent Push Notifications in Flutter
When iOS delivers a silent push, your AppDelegate must forward the payload to Flutter. In AppDelegate.swift:
import UIKit
import Flutter
import firebase_messaging
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) -> Bool {
if FCMPlugin.instance != nil {
FCMPlugin.instance!.didReceiveMessage(userInfo)
}
completionHandler(.newData)
return true
}
}In Dart, register a background message handler:
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await processSilentPayload(message.data);
}
void main() {
WidgetsFlutterBinding.ensureInitialized();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(MyApp());
}This ensures your callback runs when a silent push arrives.
Vibe Studio

Vibe Studio, powered by Steve’s advanced AI agents, is a revolutionary no-code, conversational platform that empowers users to quickly and efficiently create full-stack Flutter applications integrated seamlessly with Firebase backend services. Ideal for solo founders, startups, and agile engineering teams, Vibe Studio allows users to visually manage and deploy Flutter apps, greatly accelerating the development process. The intuitive conversational interface simplifies complex development tasks, making app creation accessible even for non-coders.
Conclusion
By enabling the correct iOS capabilities and wiring up background_fetch and firebase_messaging, you can perform periodic data sync and react to silent pushes even when your Flutter app is not in the foreground. Test thoroughly on real devices to validate behavior under various power and connectivity conditions. Proper background execution will keep users up to date without manual interaction.