Skip to content

Fix sync file structure and implement iOS BGTaskScheduler#591

Draft
Copilot wants to merge 10 commits intomainfrom
copilot/implement-sync-throttling
Draft

Fix sync file structure and implement iOS BGTaskScheduler#591
Copilot wants to merge 10 commits intomainfrom
copilot/implement-sync-throttling

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

NativeScript's module resolution prioritizes sync.${platform}.ts over sync.ts, causing the common sync logic to be skipped entirely on both platforms.

Changes

File Structure

  • sync.tssync.common.ts - shared SyncService implementation
  • sync.android.ts - exports from common, sets Android AlarmManager implementations
  • sync.ios.ts - exports from common, sets iOS BGTaskScheduler implementations

Platform files inject their implementations into the common module:

// sync.android.ts
export * from './sync.common';
import * as syncCommon from './sync.common';

syncCommon.scheduleAndroidSyncAlarm = (serviceId, delayMs) => {
  // Android AlarmManager implementation
};

When importing ~/services/sync, NativeScript loads the platform-specific file which re-exports everything from common plus platform implementations.

iOS Background Sync

  • Registers BGTaskScheduler handler with task identifier ${__APP_ID__}.sync
  • Maintains Map<serviceId, scheduledTime> for pending syncs across all services
  • Schedules single background task for earliest required sync time
  • Processes all pending syncs concurrently when task executes
  • Falls back to setTimeout on iOS < 13

Android

  • Unchanged behavior, now injected into common module instead of dynamically imported

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI changed the title [WIP] Add sync throttling for configurable sync intervals Add per-service sync throttling with background support Mar 14, 2026
Copilot AI requested a review from farfromrefug March 14, 2026 14:26
Copilot AI changed the title Add per-service sync throttling with background support Fix sync file structure and implement iOS BGTaskScheduler Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants