iOS and Android Platform-Specific Implementation¶
This document describes the implementation requirements for iOS and Android platforms.
iOS Background Limitations¶
Overview¶
iOS has strict limitations on background clipboard access. The app cannot monitor clipboard changes when in the background. However, there are several workarounds:
- App Extensions - Share extensions can access clipboard
- Shortcuts Integration - Siri Shortcuts can trigger sync
- Widgets - Home screen widgets can trigger sync
- Foreground Optimization - Optimize sync when app is active
Implementation Status¶
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)
Required Native Code¶
- App Extension (
ios/ShareExtension/): - Share extension target
- Clipboard access from extension
-
Communication with main app
-
Shortcuts Integration (
ios/Runner/AppDelegate.swift): - Handle
UIApplicationShortcutItem - Register shortcut actions
-
Trigger sync on shortcut invocation
-
Widget (
ios/Widget/): - Home screen widget target
- Quick sync button
- Status display
Next Steps¶
- Create Share Extension target in Xcode
- Implement shortcut handlers in AppDelegate
- Create widget extension
- Test on iOS device
Android 10+ Clipboard Restrictions¶
Overview¶
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
Implementation Status¶
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)
Required Native Code¶
- Foreground Service (
android/app/src/main/kotlin/.../ClipboardService.kt): - Extend
Serviceclass - Implement
startForeground()with notification - Monitor clipboard changes
-
Handle service lifecycle
-
Service Notification:
- Persistent notification (required for foreground service)
- Show sync status
-
Allow user to stop service
-
Manifest Permissions:
AndroidManifest.xml Updates Needed¶
<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>
Next Steps¶
- Create
ClipboardService.ktin Android project - Update
AndroidManifest.xmlwith permissions and service declaration - Implement notification channel
- Test on Android 10+ device
Testing¶
iOS Testing¶
- Test on iOS device (simulator has limitations)
- Test app extension functionality
- Test Siri Shortcuts integration
- Test widget functionality
- Test foreground sync performance
Android Testing¶
- Test on Android 10+ device
- Verify foreground service starts correctly
- Test notification display
- Test clipboard access with service running
- Test service lifecycle (start/stop)
Priority¶
- iOS Background (#31): Medium priority - App can work with foreground-only sync
- Android 10+ (#32): High priority - Required for Android 10+ devices