PHPackages                             projectmata/mobile-background-tasks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. projectmata/mobile-background-tasks

ActiveNativephp-plugin[Queues &amp; Workers](/categories/queues)

projectmata/mobile-background-tasks
===================================

Background task scheduling plugin for NativePHP Mobile — wraps Laravel's scheduler and runs tasks via WorkManager (Android) and BGTaskScheduler (iOS).

v1.0.0(2mo ago)02MITPHPPHP ^8.1

Since Apr 26Pushed 2mo agoCompare

[ Source](https://github.com/jomarmata24/mobile-background-tasks)[ Packagist](https://packagist.org/packages/projectmata/mobile-background-tasks)[ RSS](/packages/projectmata-mobile-background-tasks/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Projectmata Mobile Background Tasks
===================================

[](#projectmata-mobile-background-tasks)

[![Latest Version](https://camo.githubusercontent.com/c8a219148c17a4cf6e103a028b4f64010069904e36b50e736659b07e99d5100c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f6a6563746d6174612f6d6f62696c652d6261636b67726f756e642d7461736b732e737667)](https://packagist.org/packages/projectmata/mobile-background-tasks)[![Total Downloads](https://camo.githubusercontent.com/692b1f9e859a59abd67b82f087c5d8e384f08a33e4a94eee45fbaf54db811b10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f6a6563746d6174612f6d6f62696c652d6261636b67726f756e642d7461736b732e737667)](https://packagist.org/packages/projectmata/mobile-background-tasks)[![License](https://camo.githubusercontent.com/63d58c15691b7cab7de041ef52438ed77de57723853d3f996c7abe1d2c1b1beb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70726f6a6563746d6174612f6d6f62696c652d6261636b67726f756e642d7461736b732e737667)](https://packagist.org/packages/projectmata/mobile-background-tasks)

Background task scheduling plugin for [NativePHP Mobile](https://nativephp.com). 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 `BackgroundTasksWorker` and iOS `BGTaskScheduler` handlers ship as stubs — you'll fill those in to invoke your bundled artisan commands. See [Native integration](#native-integration).

Requirements
------------

[](#requirements)

- PHP `^8.1`
- Laravel `^11.0` or `^12.0` / `^13.0`
- `nativephp/mobile`
- Android: `min_version 33` (uses `androidx.work:work-runtime-ktx`)
- iOS: `min_version 16.0`

Installation
------------

[](#installation)

```
composer require projectmata/mobile-background-tasks
```

Laravel auto-discovery registers the service provider, the facade, the schedule constraint macros, and the artisan command. Then rebuild the mobile app:

```
php artisan native:run android
# or
php artisan native:run ios
```

Defining tasks
--------------

[](#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:

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('sync:data')
    ->everyFifteenMinutes()
    ->onAnyNetwork();

Schedule::command('cache:warm')
    ->hourly()
    ->onWifi()
    ->whileCharging();

Schedule::command('export:reports')
    ->daily()
    ->onWifi()
    ->whileCharging()
    ->whenIdle()
    ->longRunning();
```

After defining tasks, push them to the native runtime:

```
php artisan projectmata:background-tasks:register
```

This walks the schedule, serialises each periodic event into a task descriptor, and calls the `BackgroundTasks.Register` bridge function.

Constraint methods
------------------

[](#constraint-methods)

MethodAndroidiOS`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
-------------------

[](#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
-------

[](#php-api)

```
use Projectmata\MobileBackgroundTasks\Facades\BackgroundTasks;

// Push the current schedule to the OS scheduler
BackgroundTasks::register();

// Trigger registered tasks immediately (testing only — bypasses constraints)
BackgroundTasks::runNow();

// Cancel a single task
BackgroundTasks::cancel('com.projectmata.task.sync_data');

// Inspect what's scheduled
$registered = BackgroundTasks::getRegistered();

// Or just see the descriptors the collector would push
$tasks = BackgroundTasks::tasks();
```

JavaScript API
--------------

[](#javascript-api)

```
await window.NativePHP.BackgroundTasks.Register({ tasks: [...] });
await window.NativePHP.BackgroundTasks.RunNow();
await window.NativePHP.BackgroundTasks.Cancel({ taskId: 'com.projectmata.task.sync_data' });
const { tasks } = await window.NativePHP.BackgroundTasks.GetRegistered();
```

Bridge methods
--------------

[](#bridge-methods)

MethodParamsReturns`BackgroundTasks.Register``{ tasks: TaskDescriptor[] }``{ success, registered }``BackgroundTasks.RunNow`—`{ success, message }``BackgroundTasks.Cancel``{ taskId }``{ success, taskId }``BackgroundTasks.GetRegistered`—`{ success, tasks[] }``TaskDescriptor` shape:

```
{
    id: 'com.projectmata.task.sync_data',
    command: 'sync:data',
    intervalMinutes: 15,
    constraints: {
        network: 'any' | 'wifi' | null,
        charging: boolean,
        batteryNotLow: boolean,
        storageNotLow: boolean,
        idle: boolean,
        longRunning: boolean
    }
}
```

Native integration
------------------

[](#native-integration)

### Android

[](#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

[](#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:

```
BGTaskScheduler.shared.register(forTaskWithIdentifier: "com.projectmata.task.sync_data", using: nil) { task in
    // run the sync:data artisan command, then call task.setTaskCompleted(success: ...)
}
```

The plugin's `Register` bridge submits the request; your handler runs the actual work.

Testing
-------

[](#testing)

**Android (ADB):**

```
adb shell cmd jobscheduler run -f
```

**iOS (Xcode LLDB):**

```
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.projectmata.task.sync_data"]

```

Or just call `BackgroundTasks::runNow()` from PHP — it bypasses constraints and is intended for development only.

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance82

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

89d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f5495492f5d4cf3c05ca542a5bbf714e889fdad7a60930fdde6eacf5dfe45151?d=identicon)[ramilojomar2001@gmail.com](/maintainers/ramilojomar2001@gmail.com)

---

Top Contributors

[![jomarmata24](https://avatars.githubusercontent.com/u/64277739?v=4)](https://github.com/jomarmata24 "jomarmata24 (1 commits)")

### Embed Badge

![Health badge](/badges/projectmata-mobile-background-tasks/health.svg)

```
[![Health](https://phpackages.com/badges/projectmata-mobile-background-tasks/health.svg)](https://phpackages.com/packages/projectmata-mobile-background-tasks)
```

###  Alternatives

[illuminate/queue

The Illuminate Queue package.

20432.6M1.7k](/packages/illuminate-queue)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

728176.2k14](/packages/tallstackui-tallstackui)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k96.5k1](/packages/mike-bronner-laravel-model-caching)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21111.6k](/packages/iazaran-smart-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
