Download the PHP package projectmata/mobile-background-tasks without Composer
On this page you can find all versions of the php package projectmata/mobile-background-tasks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download projectmata/mobile-background-tasks
More information about projectmata/mobile-background-tasks
Files in projectmata/mobile-background-tasks
Package mobile-background-tasks
Short Description Background task scheduling plugin for NativePHP Mobile — wraps Laravel's scheduler and runs tasks via WorkManager (Android) and BGTaskScheduler (iOS).
License MIT
Informations about the package mobile-background-tasks
Projectmata Mobile Background Tasks
Background task scheduling plugin for NativePHP Mobile. Lets you define recurring jobs with Laravel's standard scheduler and run them via Android WorkManager and iOS BGTaskScheduler — even when the app is backgrounded or killed.
Heads-up — native runtime hookup required. The PHP, JS, and bridge layers are fully wired. The Android
BackgroundTasksWorkerand iOSBGTaskSchedulerhandlers ship as stubs — you'll fill those in to invoke your bundled artisan commands. See Native integration.
Requirements
- PHP
^8.1 - Laravel
^11.0or^12.0/^13.0 nativephp/mobile- Android:
min_version 33(usesandroidx.work:work-runtime-ktx) - iOS:
min_version 16.0
Installation
Laravel auto-discovery registers the service provider, the facade, the schedule constraint macros, and the artisan command. Then rebuild the mobile app:
Defining tasks
Use Laravel's normal scheduler in routes/console.php. The plugin adds a set of mobile-aware constraint methods you can chain on:
After defining tasks, push them to the native runtime:
This walks the schedule, serialises each periodic event into a task descriptor, and calls the BackgroundTasks.Register bridge function.
Constraint methods
| Method | Android | iOS |
|---|---|---|
onAnyNetwork() |
NetworkType.CONNECTED |
requiresNetworkConnectivity = true |
onWifi() |
NetworkType.UNMETERED |
requiresNetworkConnectivity = true |
whileCharging() |
setRequiresCharging(true) |
requiresExternalPower = true |
whenBatteryNotLow() |
setRequiresBatteryNotLow(true) |
Ignored |
whenStorageNotLow() |
setRequiresStorageNotLow(true) |
Ignored |
whenIdle() |
setRequiresDeviceIdle(true) |
Promotes to BGProcessingTask |
longRunning() |
No-op | Promotes to BGProcessingTask |
Supported intervals
everyFifteenMinutes(), everyTwentyMinutes(), everyThirtyMinutes(), hourly(), everyTwoHours(), everyThreeHours(), everyFourHours(), everySixHours(), daily().
Other Laravel scheduler frequencies are ignored by the collector — both Android WorkManager and iOS BGTaskScheduler enforce minimum periodic intervals (15 minutes on Android, ~15 minutes practical floor on iOS).
PHP API
JavaScript API
Bridge methods
| Method | Params | Returns |
|---|---|---|
BackgroundTasks.Register |
{ tasks: TaskDescriptor[] } |
{ success, registered } |
BackgroundTasks.RunNow |
— | { success, message } |
BackgroundTasks.Cancel |
{ taskId } |
{ success, taskId } |
BackgroundTasks.GetRegistered |
— | { success, tasks[] } |
TaskDescriptor shape:
Native integration
Android
This package declares androidx.work:work-runtime-ktx:2.9.1. The Register bridge function enqueues a PeriodicWorkRequest per task with the right Constraints, but the worker itself (BackgroundTasksWorker.doWork()) is a stub. Replace the body with code that invokes the bundled artisan command on the embedded NativePHP runtime — typically by calling into the same PHP runner that powers the rest of your NativePHP app.
iOS
BGTaskScheduler requires every task identifier to be listed in Info.plist > BGTaskSchedulerPermittedIdentifiers. The plugin declares the com.projectmata.task.* prefix; iOS will reject any identifier outside that prefix.
You must register a handler in your AppDelegate (or SwiftUI App) for each identifier you submit:
The plugin's Register bridge submits the request; your handler runs the actual work.
Testing
Android (ADB):
iOS (Xcode LLDB):
Or just call BackgroundTasks::runNow() from PHP — it bypasses constraints and is intended for development only.
License
MIT
All versions of mobile-background-tasks with dependencies
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0