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

套件詳情v0.0.5

icloud_storage_sync

使用 iCloud Sync Flutter 插件輕鬆同步並保護您應用程式資料,實現無縫的 iCloud 整合。

iOSmacOS
近 30 天下載
784
喜歡數
45
Pub 分數
150

安裝套件

flutter pub add icloud_storage_sync

套件介紹

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

icloud_storage_sync 套件為 iOS 與 macOS 上的 Flutter 應用程式提供無縫的 iCloud 整合,讓開發者能輕鬆地在 iCloud 中同步與安全儲存應用資料。它提供簡單的 API 來管理跨裝置的資料持久化,確保使用者可持續存取其資訊。此外,該套件以安全性為設計核心,利用 Apple 的 iCloud 服務保護敏感資料,同時維持效能與可靠性。非常適合需要跨裝置同步且設定簡單的應用程式。

適用情境

  • 跨裝置資料同步
  • 使用者資料的安全雲端備份
  • Flutter 應用中的無縫 iCloud 集成
  • 離線優先的應用程式,支援雲端同步
  • 使用者檔案和偏好持續性

主要特色

  • iOS 和 macOS 原生 iCloud 集成
  • 跨裝置自動資料同步
  • 端對端加密支援
  • 用於輕鬆實現的簡單 Flutter API
  • 強大的錯誤處理和狀態監控

適合對象

  • iOS 和 macOS Flutter 開發人員
  • 需要持久用戶數據的應用
  • 注重隱私的應用程式
  • 尋求原生雲解決方案的開發者
  • 需要最少設定的專案

使用建議

  • 需要 Apple 開發者帳戶和 iCloud 功能
  • 僅限iOS和macOS平台
  • 依賴於正確的 iCloud 權限和設定
  • 可能需要額外設定才能用於企業使用
  • 不相容 Android 或 Web 平台

原始 README

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

📦☁️ iCloud_Storage_Sync Plugin

Seamless iCloud integration for your Flutter iOS apps!

iCloud Storage Sync Banner

🌟 Introduction

iCloud_Storage_Sync simplifies iCloud storage integration, bringing powerful cloud capabilities to your Flutter iOS apps:

🔄 Effortless backup and sync of app data

📱💻 Consistent user experience across all devices

🔒 Secure storage and retrieval of important information

☁️ Seamless integration with the iCloud ecosystem

✨ Features

Feature Description
📂 Get iCloud files
⬆️ Upload files to iCloud
✏️ Rename iCloud files
🗑️ Delete iCloud files
↔️ Move iCloud files
🔍 Filter by path prefix
⏱️ Timeout support

Advanced Features:

  • 🔍 Path Filtering - Query specific subdirectories instead of entire container for better performance
  • ⏱️ Timeout Support - Set time limits on metadata queries to prevent indefinite hangs
  • 📊 Progress Tracking - Monitor upload/download progress with callbacks
  • 🔄 Stream Updates - Receive live updates as files change in iCloud

🚀 Getting Started

1. 🛠️ Installation

Add this to your pubspec.yaml:

dependencies:
  icloud_storage_sync: ^1.0.0
2. ⚙️ Install the Plugin

Run:

flutter pub get
3. 🔧 Configure Your iCloud Container ID

Update your iCloud Container ID in the example app:

In example/lib/controller/icloud_plugin_controller.dart:

final iCloudContainerId = 'iCloud.com.yourcompany.appname'; // Replace with your container ID

In example/ios/Runner/Info.plist:

<key>iCloud.com.yourcompany.appname</key>  <!-- Replace with your container ID -->

In example/ios/Runner/Runner.entitlements and RunnerDebug.entitlements:

<string>iCloud.com.yourcompany.appname</string>  <!-- Replace with your container ID -->

ℹ️ Note: Your iCloud Container ID should match the format: iCloud.<your-team-id>.<your-bundle-id>

4. 💻 Usage

Import in your Dart code:

import 'package:icloud_storage_sync/icloud_storage_sync.dart';

📋 Prerequisites

Before diving in, make sure you have:

☑️ An Apple Developer account

☑️ App ID and iCloud Container ID

☑️ iCloud capability enabled and assigned

☑️ iCloud capability configured in Xcode

🔍 See How to set up iCloud Container for step-by-step instructions.


🧰 API Examples

📥 Getting iCloud Files
Future<List<CloudFiles>> getCloudFiles({required String containerId}) async {
  return await icloudSyncPlugin.getCloudFiles(containerId: containerId);
}
📂 Gathering Files with Path Filtering & Timeout
// Gather files with optional path prefix filtering
Future<List<ICloudFile>> gatherFilesFromSubdirectory({
  required String containerId,
  required String pathPrefix,
}) async {
  return await icloudSyncPlugin.gather(
    containerId: containerId,
    relativePathPrefix: pathPrefix, // e.g., 'Documents/', 'Projects/MyApp/'
  );
}

// Gather files with timeout to prevent indefinite hangs
Future<List<ICloudFile>> gatherFilesWithTimeout({
  required String containerId,
  required Duration timeout,
}) async {
  try {
    return await icloudSyncPlugin.gather(
      containerId: containerId,
      timeout: timeout, // e.g., Duration(seconds: 30)
    );
  } on PlatformException catch (e) {
    if (e.code == 'METADATA_QUERY_TIMEOUT') {
      debugPrint('iCloud query timed out');
    }
    return [];
  }
}

// Combine both features for optimal performance
Future<List<ICloudFile>> gatherFilesOptimized({
  required String containerId,
  required String pathPrefix,
}) async {
  return await icloudSyncPlugin.gather(
    containerId: containerId,
    relativePathPrefix: pathPrefix,
    timeout: Duration(seconds: 30),
  );
}

Features:

  • 📂 relativePathPrefix - Filter to specific subdirectory for faster queries
  • ⏱️ timeout - Set time limit to prevent indefinite hangs
  • 🔄 Both parameters are optional and backwards compatible
📤 Uploading Files to iCloud
Future<void> upload({
  required String containerId,
  required String filePath,
  String? destinationRelativePath,
  StreamHandler<double>? onProgress,
}) async {
  await icloudSyncPlugin.upload(
    containerId: containerId,
    filePath: filePath,
    destinationRelativePath: destinationRelativePath,
    onProgress: onProgress,
  );
}
🏷️ Renaming iCloud Files
Future<void> rename({
  required String containerId,
  required String relativePath,
  required String newName,
}) async {
  await icloudSyncPlugin.rename(
    containerId: containerId,
    relativePath: relativePath,
    newName: newName,
  );
}
🗑️ Deleting iCloud Files
Future<void> delete({
  required String containerId,
  required String relativePath,
  required bool isDirectory
}) async {
  await icloudSyncPlugin.delete(
    containerId: containerId,
    relativePath: relativePath,
    isDirectory: isDirectory
  );
}
🔄 Replace iCloud Files
Future replaceFile({
  required String updatedFilePath,
  required String relativePath
  }) async {
    await icloudSyncPlugin.replace(
      containerId: iCloudContainerId,
      updatedFilePath: updatedFilePath,
      relativePath: relativePath,
    );
}
🔀 Moving iCloud Files
Future<void> move({
  required String containerId,
  required String fromRelativePath,
  required String toRelativePath,
}) async {
  await IcloudSyncPlatform.instance.move(
    containerId: containerId,
    fromRelativePath: fromRelativePath,
    toRelativePath: toRelativePath,
  );
}

🛠 How to set up iCloud Container and enable the capability

  1. 👤 Log in to your Apple Developer account and select 'Certificates, IDs & Profiles'.

  2. 🆔 Create an App ID (if needed) and an iCloud Containers ID:

    iCloud Container ID
  3. 🔗 Assign the iCloud Container to your App ID:

    Assign iCloud Capability
  4. 💻 In Xcode, enable iCloud capability and select your container:

    Xcode Capability

🤝 Contributing


🙏 Acknowledgements

  • Thanks to all the contributors who have helped shape this plugin
  • Apple for providing the iCloud infrastructure

Made with ❤️ by the DevCodeSpace

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。