パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.9.11

workmanager_apple

workmanager プラグインの Apple プラットフォーム (iOS/macOS) 実装。

iOSmacOS
30日間ダウンロード
27.9万
いいね数
4
Pub ポイント
150

パッケージをインストール

flutter pub add workmanager_apple

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

workmanager_apple パッケージは、workmanager プラグインの Apple プラットフォーム(iOS および macOS)サポートを提供し、Flutter アプリケーションでのバックグラウンドタスク実行を可能にします。開発者は、アプリが終了した後でも実行される定期的または1回限りのタスクをスケジュールできるようになり、Apple デバイス上で信頼性の高いバックグラウンド処理を確保できます。この実装は、iOS および macOS のシステムAPIと統合されており、プラットフォーム固有の制約や省電力機能を尊重しながら、効率的にバックグラウンド実行を管理します。

用途

  • 定期的なデータ同期のスケジューリング
  • バックグラウンドでの位置情報の更新が実行中です
  • 遅延通知の実行
  • オフラインデータ処理の実行
  • バックグラウンドタスクの継続性を維持する

主な機能

  • Apple プラットフォーム固有のバックグラウンドタスク処理
  • iOS/macOS システム API との統合
  • 定期的および一時的なタスクのサポート
  • 省電力なバックグラウンド実行
  • workmanager core とのシームレスな統合

適している対象

  • iOSでバックグラウンド処理を必要とするFlutterアプリ
  • バックグラウンドの要件を持つmacOS向けの開発者
  • 信頼できるバックグラウンドタスクスケジューリングを必要とするアプリ
  • 複数のプラットフォームで workmanager プラグインを使用するプロジェクト
  • データ同期またはモニタリング要件を持つアプリケーション

注意事項

  • Xcode プロジェクト設定で適切な構成が必要です
  • iOSにおける制限付きのバックグラウンド実行時間
  • アプリの機能でバックグラウンドモードを有効にする必要があります
  • すべてのバックグラウンドタスクタイプと互換性がありません
  • 特定の操作にはユーザーの許可が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Flutter Workmanager

pub package pub points likes popularity GitHub Workflow Status license

Execute Dart code in the background, even when your app is closed (Android and iOS). On macOS, background tasks run while the app is running or backgrounded and the Mac is awake. Perfect for data sync, file uploads, and periodic maintenance tasks.

⚠️ Experimental web support now exists via workmanager_web (Service Worker + Web Worker based background execution). See the Web (experimental) page and the package README for honest limitations and how to test it in Chrome.

📖 Documentation

Get started with background tasks in Flutter:

→ Quick Start Guide - Installation and setup

→ API Documentation - Complete Dart API reference

→ Debugging Guide - Troubleshooting help

→ Troubleshooting Guide - Why tasks stop after app close (OEM battery optimization, constraints, verification)

🎯 Use Cases

Background tasks are perfect for:

  • Sync data from API - Keep your app's data fresh
  • Upload files in background - Reliable file uploads
  • Clean up old data - Remove old files and cache
  • Fetch notifications - Check for new messages
  • Database maintenance - Optimize and clean databases

⏱ Long-Running Tasks (Android)

For work that takes longer than the regular background execution window (bulk uploads/downloads, ML processing), Android tasks can run as a foreground service with a persistent notification. Pass a foregroundServiceConfig to registerOneOffTask or registerPeriodicTask:

await Workmanager().registerOneOffTask(
  "upload-task",
  "upload_files",
  foregroundServiceConfig: ForegroundServiceConfig(
    notificationTitle: "Uploading files",
    notificationText: "Your files are being uploaded",
  ),
);

See the Quick Start guide for details and platform caveats.

🛑 Cancelling Running Work (Android)

cancelByUniqueName, cancelByTag and cancelAll stop the WorkManager worker immediately, but the Dart callback that is currently running keeps executing unless it reacts to the stop. Pass an onTaskStopped handler to executeTask inside your callbackDispatcher to be notified when a running task is stopped before it finishes:

@pragma('vm:entry-point')
void callbackDispatcher() {
  Workmanager().executeTask(
    (taskName, inputData) async {
      return true;
    },
    onTaskStopped: (taskName, stopReason) async {
      // Mark the task as cancelled / persist state, then return promptly.
    },
  );
}

The handler receives the task name and the WorkManager stop reason (cancelledByApp, timeout, preempt, ...); on Android < 12 the reason is StopReason.unknown. Android-only — iOS has no way to stop a running task. See the Customization guide for details.

🐛 Issues & Support

🚀 Example App

See the example folder for a complete working demo with all task types and platform configurations.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。

ランキング