Skip to content

iOS and Android Platform-Specific Implementation

iOS and Android Platform-Specific Implementation

Section titled “iOS and Android Platform-Specific Implementation”

This document describes the implementation requirements for iOS and Android platforms.

iOS has strict limitations on background clipboard access. The app cannot monitor clipboard changes when in the background. However, there are several workarounds:

  1. App Extensions - Share extensions can access clipboard
  2. Shortcuts Integration - Siri Shortcuts can trigger sync
  3. Widgets - Home screen widgets can trigger sync
  4. Foreground Optimization - Optimize sync when app is active

Basic Structure: Created ios_background_service.dart with:

  • Shortcut action registration
  • Widget update methods
  • Foreground sync optimization
  • App extension setup structure

Files:

  • flutter_app/lib/src/core/services/ios_background_service.dart
  • flutter_app/ios/Runner/Info.plist (updated with background modes)
  1. App Extension (ios/ShareExtension/):

    • Share extension target
    • Clipboard access from extension
    • Communication with main app
  2. Shortcuts Integration (ios/Runner/AppDelegate.swift):

    • Handle UIApplicationShortcutItem
    • Register shortcut actions
    • Trigger sync on shortcut invocation
  3. Widget (ios/Widget/):

    • Home screen widget target
    • Quick sync button
    • Status display
  1. Create Share Extension target in Xcode
  2. Implement shortcut handlers in AppDelegate
  3. Create widget extension
  4. Test on iOS device

Android 10 (API 29) and later restrict background clipboard access. Apps can only access clipboard when:

  • App is in foreground
  • App has a foreground service running

Basic Structure: Created android_foreground_service.dart with:

  • Foreground service management
  • Notification handling
  • Android version detection
  • Clipboard restriction workarounds

Files:

  • flutter_app/lib/src/core/services/android_foreground_service.dart
  • flutter_app/android/app/src/main/AndroidManifest.xml (needs updates)
  1. Foreground Service (android/app/src/main/kotlin/.../ClipboardService.kt):

    • Extend Service class
    • Implement startForeground() with notification
    • Monitor clipboard changes
    • Handle service lifecycle
  2. Service Notification:

    • Persistent notification (required for foreground service)
    • Show sync status
    • Allow user to stop service
  3. Manifest Permissions:

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<manifest>
<!-- Add foreground service permission -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application>
<!-- Add foreground service declaration -->
<service
android:name=".ClipboardService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="dataSync">
<intent-filter>
<action android:name="com.toss.CLIPBOARD_SERVICE" />
</intent-filter>
</service>
</application>
</manifest>
  1. Create ClipboardService.kt in Android project
  2. Update AndroidManifest.xml with permissions and service declaration
  3. Implement notification channel
  4. Test on Android 10+ device
  1. Test on iOS device (simulator has limitations)
  2. Test app extension functionality
  3. Test Siri Shortcuts integration
  4. Test widget functionality
  5. Test foreground sync performance
  1. Test on Android 10+ device
  2. Verify foreground service starts correctly
  3. Test notification display
  4. Test clipboard access with service running
  5. Test service lifecycle (start/stop)
  • iOS Background (#31): Medium priority - App can work with foreground-only sync
  • Android 10+ (#32): High priority - Required for Android 10+ devices