Execute scheduled background sync tasks, periodic data fetching, and web worker sync when the app is suspended.
Execute periodic background sync tasks when your app is suspended. Nativine embeds native iOS BGTaskScheduler (Background Processing / App Refresh) and Android WorkManager engines, allowing web applications to refresh data periodically, sync offline databases, and pre-fetch content.
Keeping content fresh before the user opens the application improves engagement. Nativine's Background App Service Sync plugin registers OS-level periodic work execution managers:
To register or trigger a background sync task in JavaScript, call nativine.backgroundSync.schedule():
nativine.backgroundSync.schedule({
taskId: 'sync_user_inbox',
minimumIntervalMinutes: 15,
requiresCharging: false,
requiresUnmeteredNetwork: true,
syncUrl: 'https://yourdomain.com/api/background-sync',
callback: 'onBackgroundSyncScheduled'
});
| Parameter | Type | Description |
|---|---|---|
taskId | string | Required. Unique task identifier string. |
minimumIntervalMinutes | integer | Optional. Minimum time between background runs (minimum 15 minutes). |
No. Apple's iOS BGTaskScheduler uses machine learning to schedule background tasks based on user app usage habits.
Background tasks should complete within 30 seconds to prevent OS task termination.